-
Notifications
You must be signed in to change notification settings - Fork 268
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
Add a configuration setting for a PATH prefix #98
Conversation
Plus one to this pull request. |
# Prepend the user defined path | ||
path_prefix = atom.config.get('script.path_prefix') | ||
if path_prefix | ||
process.env.PATH = [path_prefix, process.env.PATH].join(':') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a built in that makes sure to pick the right separator for the OS in use?
I've been noticing more and more Win32 related items in Atom internals, so we should be prepped for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to prepend path_prefix
to process.env.PATH
every single time run
executes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The platform specific delimiter is path.delimiter
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to prepend
path_prefix
toprocess.env.PATH
every single time run executes.
I'll look into changing this when I have a minute to site and hack away at this.
The platform specific delimiter is
path.delimiter
.
I didn't think to look into using a path delimiter vs. :
. Assuming *nix is bad though. 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path.delimiter
is a bit of a misnomer, as it means the delimiter for the environment variable for path not the directory delimiter. 😅
It will use :
on *.nix and ;
on Windows.
I'm currently a bigger fan of setting your I don't like the idea of putting in side effects that would affect other modules. |
I thought on this last night and think the best solution have a field in the |
💩 I just realized what you were saying, |
This definitely is something that doesn't belong in atom-script. Regardless, below are a few immediate findings. Turns out if you add a key under editor/core the main settings page will register that on window reload (or closing and restarting atom): # ~/.atom/config.cson
'core':
'PATH': '/Users/ecarey/.rbenv/shims:/usr/local/share/npm/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin'
...
'projectHome': '/Users/ecarey/repositories' # ~/.atom/init.coffee
path = atom.config.get('core.PATH')
if path
process.env.PATH = path A few possible difficulties with this method:
|
I like this core approach. Maybe bring it up on the Atom forums and the core devs will pitch in? |
I don't really know if this is helpful but I ended up working around this issue in one of my packages by grabbing all environment variables from the login shell, something a bit like this ended up in the final code: https://github.com/ioquatix/script-runner/blob/master/examples/environment.coffee It's interesting to consider whether or not there should be any way to customize this or not. In my package, I do this every time I need to run a script, so that if the user changes anything (e.g. rvm) they'd get the updated settings. |
Mac OS X 10.10.3 solution. I work around this issue this way: 1- open file .atom/init.coffee and add the code :
2- open the file .zshrc and add the code (with the path of your groovy/grails included[that's was the case for me adapt to your needs]):
3- DONE! Now you don't need to open Atom through the terminal to execute atom-script, you can open atom normally now. |
@ioquatix That's pretty neat! Would this correctly pick up any new virtualenvs? It seems like it's only picking up the currently defined variables. |
@rgbkrk It should do. The functionality was extracted into a npm module: https://www.npmjs.com/package/shell-environment |
Related to #5, #75, and #93. Adds ability to "shim" the path by prepending a configuration setting if available. Essentially adds a package specific for users to configure their PATHs for this plugin only. It could be extended to pull in other
env
related parts though.Configuration:
![configuration](https://cloud.githubusercontent.com/assets/1694055/2688554/4d171f46-c2ac-11e3-85e9-71fef5ba6e34.png)
Running Ruby with and without a path prefix:
![path_shim](https://cloud.githubusercontent.com/assets/1694055/2688555/4ecad2ce-c2ac-11e3-986e-15492335216a.gif)