Giter Site home page Giter Site logo

Comments (6)

felicianotech avatar felicianotech commented on July 19, 2024

@JalexChen Does this work for us or does it contradict the recent recommendation we had of not using sudo?

from cimg-node.

ryuheechul avatar ryuheechul commented on July 19, 2024

use cases of symlinking to /usr/local/bin shouldn't be limited to sudo in my opinion.
one example, entering with different shell than bash.

from cimg-node.

JalexChen avatar JalexChen commented on July 19, 2024

The symlink was utilized before in #236 but was removed at some point. IIRC it was because of attempting to use $PREFIX with workspaces and we thought it was an issue with nvm, but there is nothing wrong with the symlink.

@felicianotech i think the issue with using sudo was with npm. I think implementing the symlink for node doesn't hurt, but you shouldn't need to use sudo at all when using nvm. @ryuheechul, is there a specific reason you need this?

from cimg-node.

ryuheechul avatar ryuheechul commented on July 19, 2024

@JalexChen thanks for your reply and explanation and here are my response to that.

you shouldn't need to use sudo at all when using nvm

I agree that it's a good practice but the image shouldn't make the decision for users on that. Also some script might need sudo and npm at the same time and it might natural to call that script like below

$ cat <<EOF> script-that-needs-sudo.sh
command-that-fail-if-not-sudo
npm ...
node ...
EOF

# this will fail to find `node` and `npm`
$ sudo script-that-needs-sudo.sh

Although the better version for it should be like below, there is no guarantee that every one write like this including potential third party or unfamiliar dependencies.

$ cat <<EOF> script-that-needs-sudo-only-for-certain-commands.sh
sudo command-that-fail-if-not-sudo
npm ...
node ...
EOF

$ script-that-needs-sudo-only-for-certain-commands.sh

is there a specific reason you need this?

Yes. The specific reason for me: node, npm to be discoverable from any shell not just from bash, and even when there is no additional path is added to $PATH. Using sudo happen to fall in category.
I personally avoid using sudo as much as possible, but that might not be the case for others in a team.

I think these reasons alone are good enough to justify enabling this capability:

  • node and npm was under /usr/local/bin/ from 17.* images
  • installing node in "regular" way result in binary discoverable under /usr/local/bin/
  • official node image binaries are under /usr/local/bin/ and it's reasonable for people to expect the similarity between the official node image and cimg/node
    $ docker run --rm -it node:18-slim bash
    root@4afe58bcb460:/# which node
    /usr/local/bin/node
    root@4afe58bcb460:/# which npm
    /usr/local/bin/npm
    

Otherwise, people might just run commands like below (or whatever other hacks) themselves at some point in the CircleCI steps and feel that the image is "not that convenient".

sudo ln -s "$NVM_DIR/versions/node/$(nvm version)/bin/node" "/usr/local/bin/node"
sudo ln -s "$NVM_DIR/versions/node/$(nvm version)/bin/npm" "/usr/local/bin/npm"

from cimg-node.

JalexChen avatar JalexChen commented on July 19, 2024

hey @ryuheechul - i think these are all valid and after deliberation, we've decided to move away from nvm, especially since the cimg's should still be deterministic and reflect one specific version of node. We'll be re-implementing this shortly and sudo functionality will point to the node and npm versions in /usr/local/bin

from cimg-node.

ryuheechul avatar ryuheechul commented on July 19, 2024

Hi @JalexChen, sounds good to hear and moving away from nvm seems to be the right choice πŸ‘πŸΌ.
Thanks a lot for the update!

from cimg-node.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.