devbox icon indicating copy to clipboard operation
devbox copied to clipboard

[Bug]: Can't install [email protected]

Open jefft opened this issue 3 years ago • 9 comments

Current Behavior (bug)

I have an old Python 2 script I'd like to run in a devbox. On a clean Ubuntu 22.04.2 instance I install Devbox and init a new project, but then the devbox add [email protected] step fails:

$ curl -fsSL https://get.jetpack.io/devbox | bash
$ mkdir testproj
$ cd testproj
$ devbox init
$ devbox add [email protected]
# Get 'marked as insecure' error, so enable insecure packages with:
$ cat <<EOF > ~/.config/nixpkgs/config.nix
            {
              permittedInsecurePackages = [
                "python-2.7.18.6"
              ];
            }
EOF
# Try again:
$ export DEVBOX_DEBUG=1
$ devbox add [email protected]
ir.go:22: findProjectDir: path is                                                                                     
dir.go:66: finding devbox.json in dir: /home/jturner/testproj                                                          
dir.go:22: findProjectDir: path is               
dir.go:66: finding devbox.json in dir: /home/jturner/testproj                                                          
[DEBUG] 2023/06/10 13:23:55 go.jetpack.io/devbox/internal/boxcli/midcobra/debug.go:51: Debug mode enabled.
[DEBUG] 2023/06/10 13:23:55 go.jetpack.io/devbox/internal/impl/dir.go:22: findProjectDir: path is                      
[DEBUG] 2023/06/10 13:23:55 go.jetpack.io/devbox/internal/impl/dir.go:66: finding devbox.json in dir: /home/jturner/testproj                                                      
[DEBUG] 2023/06/10 13:23:55 go.jetpack.io/devbox/internal/nix/search.go:114: running command: /home/jturner/.nixprofile/bin/nix search --json github:NixOS/nixpkgs/8670e496ffd093b60e74e7fa53526aa5920d09eb#python2 --extra-experimental-features ca-derivations --option experimental-features nix-command flakes                                                  
[DEBUG] 2023/06/10 13:23:55 go.jetpack.io/devbox/internal/plugin/plugin.go:102: Creating files for package "[email protected]" create files           
[DEBUG] 2023/06/10 13:23:55 go.jetpack.io/devbox/internal/impl/devbox.go:918: failed to clean up script file .hooks.sh, error = remove /home/jturner/testproj/.devbox/gen/scripts/.hooks.sh.sh: no such file or directory
[DEBUG] 2023/06/10 13:23:55 go.jetpack.io/devbox/internal/impl/devbox.go:918: failed to clean up script file test.sh, error = remove /home/jturner/testproj/.devbox/gen/scripts/test.sh.sh: no such file or directory                         
[DEBUG] 2023/06/10 13:23:55 go.jetpack.io/devbox/internal/impl/devbox.go:735: current environment PATH is: /home/jturner/.nix-profile/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
[DEBUG] 2023/06/10 13:23:55 go.jetpack.io/devbox/internal/nix/nix.go:68: Running print-dev-env cmd: /home/jturner/.nix-profile/bin/nix print-dev-env /home/jturner/testproj/.devbox/gen/flake/flake.nix --extra-experimental-features ca-derivations --option experimental-features nix-command flakes --json                                                        

Error: There was an error installing nix packages                                                                      
source: Command: /home/jturner/.nix-profile/bin/nix print-dev-env /home/jturner/testproj/.devbox/gen/flake/flake.nix --extra-experimental-features ca-derivations --option experimental-features nix-command flakes --json: exit status 1     
                                                           
[DEBUG] 2023/06/10 13:23:55 go.jetpack.io/devbox/internal/boxcli/midcobra/debug.go:72: Command stderr: path '/home/jturner/testproj/.devbox/gen/flake/flake.nix' does not contain a 'flake.nix', searching up
error:                                                                                                                 
       … while calling the 'derivationStrict' builtin

         at /builtin/derivation.nix:9:12: (source not available)
                                                                                                                       
       … while evaluating derivation 'nix-shell'           
         whose name attribute is located at /nix/store/15sa051fs1iq3vymyb8076l9fy3mwj3x-source/pkgs/stdenv/generic/make-derivation.nix:302:7
                                                           
       … while evaluating attribute 'buildInputs' of derivation 'nix-shell'                                            
                             
         at /nix/store/15sa051fs1iq3vymyb8076l9fy3mwj3x-source/pkgs/stdenv/generic/make-derivation.nix:349:7:          

          348|       depsHostHost                = lib.elemAt (lib.elemAt dependencies 1) 0;
          349|       buildInputs                 = lib.elemAt (lib.elemAt dependencies 1) 1;
             |       ^                                     
          350|       depsTargetTarget            = lib.elemAt (lib.elemAt dependencies 2) 0;                           
                             
       error: Package ‘python-2.7.18.6’ in /nix/store/15sa051fs1iq3vymyb8076l9fy3mwj3x-source/pkgs/development/interpreters/python/cpython/2.7/default.nix:330 is marked as insecure, refusing to evaluate.                                   
                             
                             
       Known issues:       
        - Python 2.7 has reached its end of life after 2020-01-01. See https://www.python.org/doc/sunset-python-2/.    
                                                           
       You can install it anyway by allowing this package, using the                                                   
       following methods:    
                                                                                                                       
       a) To temporarily allow all insecure packages, you can use an environment                                       
          variable for a single invocation of the nix tools:                                                           
                                                                                                                       
            $ export NIXPKGS_ALLOW_INSECURE=1              
                                                                                                                       
        Note: For `nix shell`, `nix build`, `nix develop` or any other Nix 2.4+                                        
        (Flake) command, `--impure` must be passed in order to read this
        environment variable. 

       b) for `nixos-rebuild` you can add ‘python-2.7.18.6’ to
          `nixpkgs.config.permittedInsecurePackages` in the configuration.nix,
          like so:

            {
              nixpkgs.config.permittedInsecurePackages = [
                "python-2.7.18.6"
              ];
            }

       c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
          ‘python-2.7.18.6’ to `permittedInsecurePackages` in
          ~/.config/nixpkgs/config.nix, like so:
            {
              permittedInsecurePackages = [
                "python-2.7.18.6"
              ];
            }

[DEBUG] 2023/06/10 13:23:55 go.jetpack.io/devbox/internal/boxcli/midcobra/debug.go:74: 
ExecutionID:7676bca9e53440e3842b7b0f1d1973b1
<nil>
[DEBUG] 2023/06/10 13:23:55 go.jetpack.io/devbox/internal/impl/dir.go:22: findProjectDir: path is 
[DEBUG] 2023/06/10 13:23:55 go.jetpack.io/devbox/internal/impl/dir.go:66: finding devbox.json in dir: /home/jturner/testproj
[DEBUG] 2023/06/10 13:23:55 go.jetpack.io/devbox/internal/impl/dir.go:22: findProjectDir: path is 
[DEBUG] 2023/06/10 13:23:55 go.jetpack.io/devbox/internal/impl/dir.go:66: finding devbox.json in dir: /home/jturner/testproj

Full transcript attached.

Expected Behavior (fix) Dependency should install.

Additional context Please include the output of devbox version -v and a copy of your devbox.json file.

jturner@radish-2023:~/testproj$ devbox version -v
Version:     0.5.4
Platform:    linux_amd64
Commit:      92bb293af46fe6869648c20e4a6476dc83df0092
Commit Time: 2023-06-01T21:35:06Z
Go Version:  go1.20.4
Launcher:    0.2.0

jturner@radish-2023:~/testproj$ cat devbox.json 
{
  "packages": [],
  "shell": {
    "init_hook": [
      "echo 'Welcome to devbox!' > /dev/null"
    ],
    "scripts": {
      "test": [
        "echo \"Error: no test specified\" && exit 1"
      ]
    }
  }
}

jefft avatar Jun 10 '23 13:06 jefft

I think this is related to #462 -- There should be a way to set the insecure packages bit in your devbox.json so you can circumvent this error, or we should make it easier to modify the nix.conf file to set it

Lagoja avatar Jun 12 '23 15:06 Lagoja

As of 0.5.7, we've now added a way to install insecure packages with Devbox. You can install this package using:

devbox add [email protected] --allow-insecure

Of course, using unsupported packages is a "use at your own risk" sort of scenario :)

Lagoja avatar Jul 13 '23 21:07 Lagoja

Very nice, thanks!

jefft avatar Jul 20 '23 11:07 jefft

excuse me, please help me. I also am in same trouble, but I've not understood @jefft did solve yet.

anyone can help?

dir.go:22: findProjectDir: path is 
dir.go:66: finding devbox.json in dir: /home/ub01/project/paperiot
dir.go:22: findProjectDir: path is 
dir.go:66: finding devbox.json in dir: /home/ub01/project/paperiot
[DEBUG] 2023/08/01 16:00:37 go.jetpack.io/devbox/internal/boxcli/midcobra/debug.go:51: Debug mode enabled.
[DEBUG] 2023/08/01 16:00:37 go.jetpack.io/devbox/internal/impl/dir.go:22: findProjectDir: path is 
[DEBUG] 2023/08/01 16:00:37 go.jetpack.io/devbox/internal/impl/dir.go:66: finding devbox.json in dir: /home/ub01/project/paperiot
[DEBUG] 2023/08/01 16:00:38 go.jetpack.io/devbox/internal/nix/search.go:95: running command: /nix/var/nix/profiles/default/bin/nix search --json github:NixOS/nixpkgs/af8cd5ded7735ca1df1a1174864daab75feeb64a#nodejs_20 --extra-experimental-features ca-derivations --option experimental-features nix-command flakes
Reinitialized existing Git repository in /home/ub01/project/paperiot/.devbox/gen/flake/.git/
[DEBUG] 2023/08/01 16:00:38 go.jetpack.io/devbox/internal/impl/devbox.go:758: current environment PATH is: /mnt/c/Users/admin.DESKTOP-1PF4AT3/Documents/Dev/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/home/ub01/.vscode-server/bin/2ccd690cbff1569e4a83d7c43d45101f817401dc/bin/remote-cli:/mnt/c/Users/admin.DESKTOP-1PF4AT3/Documents/Dev/.local/bin:/home/ub01/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Users/admin.DESKTOP-1PF4AT3/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/admin.DESKTOP-1PF4AT3/AppData/Local/Programs/Microsoft VS Code/bin:/snap/bin:~/.local/bin:~/.local/bin
[DEBUG] 2023/08/01 16:00:38 go.jetpack.io/devbox/internal/nix/nix.go:72: Running print-dev-env cmd: /nix/var/nix/profiles/default/bin/nix print-dev-env /home/ub01/project/paperiot/.devbox/gen/flake/flake.nix --extra-experimental-features ca-derivations --option experimental-features nix-command flakes --json

Error: There was an error installing nix packages
source: Command: /nix/var/nix/profiles/default/bin/nix print-dev-env /home/ub01/project/paperiot/.devbox/gen/flake/flake.nix --extra-experimental-features ca-derivations --option experimental-features nix-command flakes --json: exit status 1

[DEBUG] 2023/08/01 16:00:39 go.jetpack.io/devbox/internal/boxcli/midcobra/debug.go:72: Command stderr: path '/home/ub01/project/paperiot/.devbox/gen/flake/flake.nix' does not contain a 'flake.nix', searching up
warning: Git tree '/home/ub01/project/paperiot/.devbox/gen/flake' is dirty
warning: updating lock file '/home/ub01/project/paperiot/.devbox/gen/flake/flake.lock':
• Added input 'flake-utils':
    'github:numtide/flake-utils/919d646de7be200f3bf08cb76ae1f09402b6f9b4' (2023-07-11)
• Added input 'flake-utils/systems':
    'github:nix-systems/default/da67096a3b9bf56a91d16901293e51ba5b49a27e' (2023-04-09)
• Added input 'nixpkgs':
    'github:NixOS/nixpkgs/af8cd5ded7735ca1df1a1174864daab75feeb64a' (2023-07-23)
• Added input 'nixpkgs-af8cd5':
    'github:NixOS/nixpkgs/af8cd5ded7735ca1df1a1174864daab75feeb64a' (2023-07-23)
The following paths are ignored by one of your .gitignore files:
flake.lock
hint: Use -f if you really want to add them.
hint: Turn this message off by running
hint: "git config advice.addIgnoredFile false"
error:
       … while updating the lock file of flake 'git+file:///home/ub01/project/paperiot/.devbox/gen/flake'

       error: program 'git' failed with exit code 1

[DEBUG] 2023/08/01 16:00:39 go.jetpack.io/devbox/internal/boxcli/midcobra/debug.go:74: 
ExecutionID:b69274b6602b4072946d3711ebb38f65
<nil>
[DEBUG] 2023/08/01 16:00:39 go.jetpack.io/devbox/internal/impl/dir.go:22: findProjectDir: path is 
[DEBUG] 2023/08/01 16:00:39 go.jetpack.io/devbox/internal/impl/dir.go:66: finding devbox.json in dir: /home/ub01/project/paperiot

what I already did are

  • remove exist nix multi user and its group, channel, following here ( https://nixos.org/manual/nix/stable/installation/uninstall.html )
  • reinstall it

roccho-dev avatar Aug 01 '23 07:08 roccho-dev

@PorcoRosso85 I don't know what's wrong with your env, but I've verified the exact commands posted in my bug description (but with --allow-insecure) successfully install Python in a clean Ubuntu 22.04.2 LTS image.

jefft avatar Aug 01 '23 12:08 jefft

@jefft Thanks. I've tried what you teach me.

But it seems to be not good

ub01@DESKTOP-1PF4AT3:/home/ub01/project/paperiot$ devbox add nodejs --allow-insecure
...
...
[DEBUG] 2023/08/02 08:08:09 go.jetpack.io/devbox/internal/nix/nix.go:72: Running print-dev-env cmd: /nix/var/nix/profiles/default/bin/nix print-dev-env /home/ub01/project/paperiot/.devbox/gen/flake/flake.nix --extra-experimental-features ca-derivations --option experimental-features nix-command flakes --json

Error: There was an error installing nix packages
source: Command: /nix/var/nix/profiles/default/bin/nix print-dev-env /home/ub01/project/paperiot/.devbox/gen/flake/flake.nix --extra-experimental-features ca-derivations --option experimental-features nix-command flakes --json: exit status 1

[DEBUG] 2023/08/02 08:08:09 go.jetpack.io/devbox/internal/boxcli/midcobra/debug.go:72: Command stderr: path '/home/ub01/project/paperiot/.devbox/gen/flake/flake.nix' does not contain a 'flake.nix', searching up
warning: Git tree '/home/ub01/project/paperiot/.devbox/gen/flake' is dirty
warning: updating lock file '/home/ub01/project/paperiot/.devbox/gen/flake/flake.lock':
• Added input 'flake-utils':
    'github:numtide/flake-utils/919d646de7be200f3bf08cb76ae1f09402b6f9b4' (2023-07-11)
• Added input 'flake-utils/systems':
    'github:nix-systems/default/da67096a3b9bf56a91d16901293e51ba5b49a27e' (2023-04-09)
• Added input 'nixpkgs':
    'github:NixOS/nixpkgs/af8cd5ded7735ca1df1a1174864daab75feeb64a' (2023-07-23)
• Added input 'nixpkgs-af8cd5':
    'github:NixOS/nixpkgs/af8cd5ded7735ca1df1a1174864daab75feeb64a' (2023-07-23)
The following paths are ignored by one of your .gitignore files:
flake.lock
hint: Use -f if you really want to add them.
hint: Turn this message off by running
hint: "git config advice.addIgnoredFile false"
error:
       … while updating the lock file of flake 'git+file:///home/ub01/project/paperiot/.devbox/gen/flake'

       error: program 'git' failed with exit code 1

[DEBUG] 2023/08/02 08:08:09 go.jetpack.io/devbox/internal/boxcli/midcobra/debug.go:74: 
ExecutionID:f880065f25554e2594f6c6f83bbc710a
<nil>
[DEBUG] 2023/08/02 08:08:09 go.jetpack.io/devbox/internal/impl/dir.go:22: findProjectDir: path is 
[DEBUG] 2023/08/02 08:08:09 go.jetpack.io/devbox/internal/impl/dir.go:66: finding devbox.json in dir: /home/ub01/project/paperiot

roccho-dev avatar Aug 01 '23 23:08 roccho-dev

@jefft Thanks. I've tried what you teach me.

But it seems to be not good

ub01@DESKTOP-1PF4AT3:/home/ub01/project/paperiot$ devbox add nodejs --allow-insecure
...
...
[DEBUG] 2023/08/02 08:08:09 go.jetpack.io/devbox/internal/nix/nix.go:72: Running print-dev-env cmd: /nix/var/nix/profiles/default/bin/nix print-dev-env /home/ub01/project/paperiot/.devbox/gen/flake/flake.nix --extra-experimental-features ca-derivations --option experimental-features nix-command flakes --json

Error: There was an error installing nix packages
source: Command: /nix/var/nix/profiles/default/bin/nix print-dev-env /home/ub01/project/paperiot/.devbox/gen/flake/flake.nix --extra-experimental-features ca-derivations --option experimental-features nix-command flakes --json: exit status 1

[DEBUG] 2023/08/02 08:08:09 go.jetpack.io/devbox/internal/boxcli/midcobra/debug.go:72: Command stderr: path '/home/ub01/project/paperiot/.devbox/gen/flake/flake.nix' does not contain a 'flake.nix', searching up
warning: Git tree '/home/ub01/project/paperiot/.devbox/gen/flake' is dirty
warning: updating lock file '/home/ub01/project/paperiot/.devbox/gen/flake/flake.lock':
• Added input 'flake-utils':
    'github:numtide/flake-utils/919d646de7be200f3bf08cb76ae1f09402b6f9b4' (2023-07-11)
• Added input 'flake-utils/systems':
    'github:nix-systems/default/da67096a3b9bf56a91d16901293e51ba5b49a27e' (2023-04-09)
• Added input 'nixpkgs':
    'github:NixOS/nixpkgs/af8cd5ded7735ca1df1a1174864daab75feeb64a' (2023-07-23)
• Added input 'nixpkgs-af8cd5':
    'github:NixOS/nixpkgs/af8cd5ded7735ca1df1a1174864daab75feeb64a' (2023-07-23)
The following paths are ignored by one of your .gitignore files:
flake.lock
hint: Use -f if you really want to add them.
hint: Turn this message off by running
hint: "git config advice.addIgnoredFile false"
error:
       … while updating the lock file of flake 'git+file:///home/ub01/project/paperiot/.devbox/gen/flake'

       error: program 'git' failed with exit code 1

[DEBUG] 2023/08/02 08:08:09 go.jetpack.io/devbox/internal/boxcli/midcobra/debug.go:74: 
ExecutionID:f880065f25554e2594f6c6f83bbc710a
<nil>
[DEBUG] 2023/08/02 08:08:09 go.jetpack.io/devbox/internal/impl/dir.go:22: findProjectDir: path is 
[DEBUG] 2023/08/02 08:08:09 go.jetpack.io/devbox/internal/impl/dir.go:66: finding devbox.json in dir: /home/ub01/project/paperiot

update

I could add a package, and could join virtual shell. then, I encounted another stage of error

(devbox) ub01@DESKTOP-1PF4AT3:/home/ub01/project/lspext$ npm install -g [email protected]
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /nix/store/1gnvy2dhh311c900hzyw6ppjdhnir2s5-nodejs-20.5.0/lib/node_modules/npm
npm ERR! dest /nix/store/1gnvy2dhh311c900hzyw6ppjdhnir2s5-nodejs-20.5.0/lib/node_modules/.npm-oMTuarbo
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/nix/store/1gnvy2dhh311c900hzyw6ppjdhnir2s5-nodejs-20.5.0/lib/node_modules/npm' -> '/nix/store/1gnvy2dhh311c900hzyw6ppjdhnir2s5-nodejs-20.5.0/lib/node_modules/.npm-oMTuarbo'
npm ERR!  [Error: EACCES: permission denied, rename '/nix/store/1gnvy2dhh311c900hzyw6ppjdhnir2s5-nodejs-20.5.0/lib/node_modules/npm' -> '/nix/store/1gnvy2dhh311c900hzyw6ppjdhnir2s5-nodejs-20.5.0/lib/node_modules/.npm-oMTuarbo'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'rename',
npm ERR!   path: '/nix/store/1gnvy2dhh311c900hzyw6ppjdhnir2s5-nodejs-20.5.0/lib/node_modules/npm',
npm ERR!   dest: '/nix/store/1gnvy2dhh311c900hzyw6ppjdhnir2s5-nodejs-20.5.0/lib/node_modules/.npm-oMTuarbo'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in: /mnt/c/Users/admin.DESKTOP-1PF4AT3/Documents/Dev/.npm/_logs/2023-08-02T00_19_34_112Z-debug-0.log

roccho-dev avatar Aug 02 '23 00:08 roccho-dev

update

I've tried, but this solution is not enough

chmod 777 /nix/
chmod 777 /nix/store

roccho-dev avatar Aug 02 '23 01:08 roccho-dev

@PorcoRosso85, the point of Nix is to be immutable, so you should never use npm -g / npm --global.

If you need such an old version of npm, install it to your project directory with npm install [email protected] and invoke with ./node_modules/.bin/npm

jefft avatar Aug 02 '23 04:08 jefft