Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow deno install when running as deno user #170

Open
felipecrs opened this issue Aug 26, 2021 · 9 comments
Open

Allow deno install when running as deno user #170

felipecrs opened this issue Aug 26, 2021 · 9 comments

Comments

@felipecrs
Copy link
Contributor

felipecrs commented Aug 26, 2021

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

@wperron
Copy link
Contributor

wperron commented Aug 26, 2021

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

@hayd
Copy link
Contributor

hayd commented Aug 26, 2021

see also #109

@felipecrs
Copy link
Contributor Author

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.

@wperron
Copy link
Contributor

wperron commented Aug 26, 2021

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.

@felipecrs
Copy link
Contributor Author

felipecrs commented Aug 26, 2021

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/[email protected]/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.

@wperron
Copy link
Contributor

wperron commented Aug 26, 2021

❯ 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/[email protected]/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 😛

@felipecrs
Copy link
Contributor Author

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

@wperron
Copy link
Contributor

wperron commented Aug 27, 2021

@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.

@felipecrs
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants