-
Notifications
You must be signed in to change notification settings - Fork 58
Fix nodejs
: Create directory before executing script
#183
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
Conversation
@mafredri @matifali Can you guys please have a look at this? Thanks! Edit:
But the directory does exists. When I set this in the module config:
it works. But this seems to not work by default:
Any idea why this is the case and how to fix it? |
Ah right, it makes sense that the latter doesn't work because we're trying to install it into the literal I think one question we need to ask is, should our modules support variables names in inputs? If so, we need to handle that consistently across our modules. One approach is to allow "well known" variables/syntax, like Allowing variable expansion is always a bit iffy, IMO, as it could be possible to inject things or make the script behave in unexpected ways. Just imagine if someone gave this as an input: Next week when @matifali is back, I'd love to have his input on this as well. |
I think its a sane choice to not allow variable names as directories. |
What's the best way to achieve this? |
@TheZoker We can treat the input as a relative directory to For example, module "nodejs" {
source = "registry.coder.com/modules/nodejs/coder"
version = "1.0.8"
agent_id = coder_agent.main.id
nvm_install_prefix = ".nvm". # relative to $HOME
node_versions = [
"18",
"20"
]
default_node_version = "20"
} and then within the export NVM_DIR="$HOME/$${INSTALL_PREFIX}/nvm"
mkdir -p "$NVM_DIR" What do you think @mafredri? |
Something I did not notice during my testing was, that the directory for
nvm
needs to be created first before the script can be installed. This PR fixes this.