denoland/deno_docker

Allow `deno install` when running as `deno` user

Opened this issue · 9 comments

Probably the DENO_INSTALL_ROOT will need to be changed to a folder where the non-root user has permission to write. The deno binary could be installed to $DENO_INSTALL_ROOT/bin instead and this folder added to PATH.

It could probably be /opt/deno: https://unix.stackexchange.com/a/20668/427940

Probably easier to instead change the DENO_DIR to be $HOME/.deno instead of the current /deno-dir

hayd commented

see also #109

It's supposed to be accessible by both root and deno, so I don't think the standard home folder should apply here.

For the same reason, the devcontainers scripts installs nvm to a folder different than the normal ~/.nvm. And similarly for SDKMAN!, which otherwise would be ~/.sdkman.

It's supposed to be accessible by both root and deno, so I don't think the standard home folder should apply here.

For the same reason, the devcontainers scripts installs nvm to a folder different than the normal ~/.nvm. And similarly for SDKMAN!, which otherwise would be ~/.sdkman.

deno install (and all other deno commands for that matter) work without having DENO_DIR set, deno just chooses a path where to install the files and dependencies. Worth noting that deno install also requires having $DENO_DIR/bin added to your PATH for installed apps to be accessible directly by the command line.

I think I did not quite understand how what you said applies to my comment. But:

docker run --rm --user deno denoland/deno:latest install https://deno.land/std/examples/welcome.ts
Download https://deno.land/std/examples/welcome.ts
Warning Implicitly using latest version (0.106.0) for https://deno.land/std/examples/welcome.ts
Download https://deno.land/std@0.106.0/examples/welcome.ts
Check https://deno.land/std/examples/welcome.ts
error: Permission denied (os error 13)
docker run --rm --user deno denoland/deno:latest bash -c 'unset DENO_DIR; deno install https://deno.land/std/examples/welcome.ts'
error: Could not create TypeScript compiler cache location: "/home/deno/.cache/deno/gen"
Check the permission of the directory.
❯ docker run --rm --user deno denoland/deno:latest install https://deno.land/std/examples/welcome.ts
Download https://deno.land/std/examples/welcome.ts
Warning Implicitly using latest version (0.106.0) for https://deno.land/std/examples/welcome.ts
Download https://deno.land/std@0.106.0/examples/welcome.ts
Check https://deno.land/std/examples/welcome.ts
error: Permission denied (os error 13)

Setting DENO_DIR to be inside the deno user's home directory will fix that 😛

@wperron do you agree that deno install must work out-of-the-box for both root and deno user?

@wperron do you agree that deno install must work out-of-the-box for both root and deno user?

Sorta: I think the use cases for deno install in a Docker container are few and far between. VSCode devcontainers are certainly one of the use cases and is likely to become more common imo. I definitely don't want to have to have a subcommand that's just outright broken.

I think the best way to make deno install work no matter the user would be to remove the DENO_INSTALL_ROOT variable and let deno default to $HOME/.deno or something like that.

I think the best way to make deno install work no matter the user would be to remove the DENO_INSTALL_ROOT variable and let deno default to $HOME/.deno or something like that.

The problem is that $HOME/.deno/bin won't be on the PATH in the Dockerfile. And if we add it as an ENV, it would apply for all the users inside of the container (root and deno), and of course, we don't want root user trying to read binaries in deno's home, or the opposite.