[BUG] Unable to run claude code in FreeBSD Linux emulator jail
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Created a Linux jail in FreeBSD, this is like running on Ubuntu 22.04, it should work, but it fails.
```root@aitools:/# curl -fsSL https://claude.ai/install.sh | bash
Setting up Claude Code...
6 | // and may be used to improve Anthropic's products, including training models.
7 | // You are responsible for reviewing any code suggestions before use.
8 |
9 | // (c) Anthropic PBC. All rights reserved. Use is subject to the Legal Agreements outlined here: https://code.claude.com/docs/en/legal-and-compliance.
10 |
11 | var nfB=Object.create;var{getPrototypeOf:rfB,defineProperty:Fe,getOwnPropertyNames:spH,getOwnPropertyDescriptor:ofB}=Object,epH=Object.prototype.hasOwnProperty,mA=(H,$,A)=>{for(let L of spH($))if(!epH.call(H,L)&&L!=="default")Fe(H,L,{get:()=>$[L],enumerable:!0});if(A){for(let L of spH($))if(!epH.call(A,L)&&L!=="default")Fe(A,L,{get:()=>$[L],enumerable:!0});return A}},R=(H,$,A)=>{A=H!=null?nfB(rfB(H)):{};let L=$||!H||!H.__esModule?Fe(A,"default",{value:H,enumerable:!0}):A;for(let I of spH(H))if(!epH.call(L,I))Fe(L,I,{get:()=>H[I],enumerable:!0});return L},ukA=new WeakMap,Lb=(H)=>{var $=ukA.get(H),A;if($)return $;if($=Fe({},"__esModule",{value:!0}),H&&typeof H==="object"||typeof H==="function")spH(H).map((L)=>!epH.call($,L)&&Fe($,L,{get:()=>H[L],enumerable:!(A=ofB(H,L))||A.enumerable}));return ukA.set(H,$),$},N=(H,$)=>()=>($||H(($={exports:{}}).exports,$),$.exports);var UD=(H,$)=>{for(var A in $)Fe(H,A,{get:$[A],enumerable:!0,configurable:!0,set:(L)=>$[A]=()=>L})};var K=(H,$)=>()=>(H&&($=H(H=0)),$);var gkA=N((f | ... truncated
ENOENT: no such file or directory, lstat '/'
path: "/",
syscall: "lstat",
errno: -2,
code: "ENOENT"
at ymA (/$bunfs/root/claude:11:30009)
at <anonymous> (/$bunfs/root/claude:11:40632)
at <anonymous> (/$bunfs/root/claude:11:1003)
at <anonymous> (/$bunfs/root/claude:12:167)
at <anonymous> (/$bunfs/root/claude:11:1003)
at <anonymous> (/$bunfs/root/claude:14:238)
at <anonymous> (/$bunfs/root/claude:11:1003)
at <anonymous> (/$bunfs/root/claude:14:9079)
at <anonymous> (/$bunfs/root/claude:11:1003)
Bun v1.3.5 (Linux x64 baseline)```
What Should Happen?
It should work
Error Messages/Logs
Steps to Reproduce
FreeBSD Version
Latest FreeBSD FreeBSD 15.0-RELEASE
Enable Linux Compatibility
sysrc linux_enable="YES"
service linux start
echo 'linux64_load="YES"' >> /boot/loader.conf
Bootstrap Linux Userland with Debootstrap
pkg install debootstrap
# Create jail directory
mkdir -p /jails/aitools
# Bootstrap Ubuntu 22.04 (jammy) into the jail
debootstrap --arch=amd64 jammy /jails/aitools http://archive.ubuntu.com/ubuntu
Jail creation
# /etc/jail.conf
aitools {
# HOSTNAME/PATH
host.hostname = "aitools.jail";
path = "/jails/aitools";
# NETWORK - inherit host's network stack (simplest, has full internet access)
ip4 = inherit;
ip6 = inherit;
# LOGGING
exec.consolelog = "/var/log/jail_console_${name}.log";
# Mount devfs
mount.devfs;
devfs_ruleset = 4;
# Allow Linux compatibility mounts
allow.mount;
allow.mount.devfs;
allow.mount.fdescfs;
allow.mount.procfs;
allow.mount.linprocfs;
allow.mount.linsysfs;
allow.mount.tmpfs;
enforce_statfs = 1;
# Networking
allow.raw_sockets;
# For Linux jails: no FreeBSD rc scripts
exec.start = "";
exec.stop = "";
# Persist
persist;
}
Enable the jail service:
sysrc jail_enable="YES"
sysrc jail_parallel_start="YES"
Configure the Linux Jail
Set up basic configuration inside the jail:
# Set up DNS resolution
echo "nameserver 1.1.1.1" > /jails/aitools/etc/resolv.conf
# Set hostname
echo "aitools" > /jails/aitools/etc/hostname
# Configure apt sources
cat > /jails/aitools/etc/apt/sources.list << 'EOF'
deb http://archive.ubuntu.com/ubuntu jammy main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu jammy-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu jammy-security main restricted universe multiverse
EOF
Mount Required Filesystems
Create a script to mount Linux filesystems before starting the jail. Add to /etc/fstab.aitools:
linprocfs /jails/aitools/proc linprocfs rw 0 0
linsysfs /jails/aitools/sys linsysfs rw 0 0
tmpfs /jails/aitools/dev/shm tmpfs rw,mode=1777 0 0
devfs /jails/aitools/dev devfs rw 0 0
Create mount points and mount:
mkdir -p /jails/aitools/proc /jails/aitools/sys /jails/aitools/dev/shm
mount -F /etc/fstab.aitools -a
Start and Enter the Jail
Start the jail:
service jail start aitools
Enter the jail using Linux shell:
jexec aitools /bin/bash
Update and Install Essential Packages
Inside the jail, update the system and install prerequisites:
# Update package lists
apt update
# Upgrade existing packages
apt upgrade -y
# Install essential tools
apt install -y curl wget ca-certificates gnupg
Claude installation
root@aitools:/# curl -fsSL https://claude.ai/install.sh | bash
Setting up Claude Code...
6 | // and may be used to improve Anthropic's products, including training models.
7 | // You are responsible for reviewing any code suggestions before use.
8 |
9 | // (c) Anthropic PBC. All rights reserved. Use is subject to the Legal Agreements outlined here: https://code.claude.com/docs/en/legal-and-compliance.
10 |
11 | var nfB=Object.create;var{getPrototypeOf:rfB,defineProperty:Fe,getOwnPropertyNames:spH,getOwnPropertyDescriptor:ofB}=Object,epH=Object.prototype.hasOwnProperty,mA=(H,$,A)=>{for(let L of spH($))if(!epH.call(H,L)&&L!=="default")Fe(H,L,{get:()=>$[L],enumerable:!0});if(A){for(let L of spH($))if(!epH.call(A,L)&&L!=="default")Fe(A,L,{get:()=>$[L],enumerable:!0});return A}},R=(H,$,A)=>{A=H!=null?nfB(rfB(H)):{};let L=$||!H||!H.__esModule?Fe(A,"default",{value:H,enumerable:!0}):A;for(let I of spH(H))if(!epH.call(L,I))Fe(L,I,{get:()=>H[I],enumerable:!0});return L},ukA=new WeakMap,Lb=(H)=>{var $=ukA.get(H),A;if($)return $;if($=Fe({},"__esModule",{value:!0}),H&&typeof H==="object"||typeof H==="function")spH(H).map((L)=>!epH.call($,L)&&Fe($,L,{get:()=>H[L],enumerable:!(A=ofB(H,L))||A.enumerable}));return ukA.set(H,$),$},N=(H,$)=>()=>($||H(($={exports:{}}).exports,$),$.exports);var UD=(H,$)=>{for(var A in $)Fe(H,A,{get:$[A],enumerable:!0,configurable:!0,set:(L)=>$[A]=()=>L})};var K=(H,$)=>()=>(H&&($=H(H=0)),$);var gkA=N((f | ... truncated
ENOENT: no such file or directory, lstat '/'
path: "/",
syscall: "lstat",
errno: -2,
code: "ENOENT"
at ymA (/$bunfs/root/claude:11:30009)
at <anonymous> (/$bunfs/root/claude:11:40632)
at <anonymous> (/$bunfs/root/claude:11:1003)
at <anonymous> (/$bunfs/root/claude:12:167)
at <anonymous> (/$bunfs/root/claude:11:1003)
at <anonymous> (/$bunfs/root/claude:14:238)
at <anonymous> (/$bunfs/root/claude:11:1003)
at <anonymous> (/$bunfs/root/claude:14:9079)
at <anonymous> (/$bunfs/root/claude:11:1003)
Bun v1.3.5 (Linux x64 baseline)
Claude Model
None
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.16
Platform
Anthropic API
Operating System
Other
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
9 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
👎 no. these are native freebsd installations, I am trying to run it on the linux emulator.
Pity. I had been holding out for linuxulator as my fallback plan. _ho-hum_
Same here. Set everything up this morning and received the same error. Fallback plan thwarted.
Can you collect some more diagnostic info from the attempt? E.g. start with
bash -x install.shto see the context in which the lstat happens?@emaste weird enough, but now it's not the bash script which fails but the binary downloaded
trying to run strace inside (if that useful... not sure)
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
https://github.com/anthropics/claude-code/issues/30640#issuecomment-4228446210 suggests that this path is now the golden way! So thi sis more "Overcome by events" versus "Not Planned." I don't know whether the jail component works, but the linuxulator seems the preferred way for the time being.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.