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

Setting path doesn't work. #2

Closed
cj opened this issue Feb 16, 2012 · 10 comments
Closed

Setting path doesn't work. #2

cj opened this issue Feb 16, 2012 · 10 comments

Comments

@cj
Copy link
Contributor

cj commented Feb 16, 2012

Hi,

So I have:

{
    "cmd_config": [{
    "exec_args": {
      "path": "/usr/local/bin:$PATH"
    }
  }],
    "input_widget": {
        "syntax": "Packages/ShellScript/Shell-Unix-Generic.tmLanguage"
    }
}

but it will not run commands. If I make cmd_config an empty array it will run commands just fine.

I have this for my coffee-script build and it works just fine:

{
   "cmd": ["/usr/local/bin/coffee", "-p", "$file"],
   "selector": "source.coffee",
   "path": "/usr/local/bin:$PATH"
}

p.s. thank you for such a great plugin.

@misfo misfo closed this as completed in 1a46f81 Feb 16, 2012
@misfo
Copy link
Owner

misfo commented Feb 16, 2012

exec_args is meant to be used for configuring specific commands based on a regex. I added a default_exec_args config that allows you to set a configuration to be used for all commands. The README is updated with the details.

In your case, if you put the following in your Packages/User/Shell Turtlestein.sublime-settings you should be good:

{
  "default_exec_args": {
    "path": "/usr/local/bin:$PATH"
  },
  "cmd_config": [
    // any additional configuration you want for specific commands
  ]
}

@cj
Copy link
Contributor Author

cj commented Feb 16, 2012

Thank you for the quick response and patch. I just tried it (restarted sublime) but it's still running under the same path and not the one i specified.....

@misfo
Copy link
Owner

misfo commented Feb 16, 2012

Can you make sure the plugin is updated and the invalid cmd_config value you were using above is removed? Otherwise, Ctrl+~ will bring up a console that will show any errors that may be occurring.

@cj
Copy link
Contributor Author

cj commented Feb 16, 2012

I have the latest version and this is what I have:

{
  "default_exec_args": {
    "path": "/usr/local/bin:$PATH"
  },
  "cmd_config": [],
  "input_widget": {
    "syntax": "Packages/ShellScript/Shell-Unix-Generic.tmLanguage"
  }
}

The only error I get in that console is no command for selector: noop:

@misfo
Copy link
Owner

misfo commented Feb 16, 2012

Pasting that exact text into my settings file and running echo $PATH shows that /usr/local/bin has been added to the beginning of my path (redundantly, in my case).

Pasting this into the sublime console will tell you if Sublime is picking up your settings your default_exec_args correctly:

sublime.load_settings("Shell Turtlestein.sublime-settings").get('default_exec_args')

@misfo
Copy link
Owner

misfo commented Feb 16, 2012

Also, are you using the package manager? I'm not sure if that thing automatically pushes out new commits from github or not...

@cj
Copy link
Contributor Author

cj commented Feb 16, 2012

So It looks like it is added it, but something is wrong as I get:

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:334:in `bin_path': can't find executable rails for railties-3.1.2 (Gem::Exception)
    from /Users/cj/.rvm/gems/ruby-1.9.3-p0@global/bin/rails:19

I had "path": "/Users/cj/.rvm/gems/ruby-1.9.3-p0@global/bin:$PATH" is there a way to just run source ~/.profile before every command? Because if I run source ~/.profile && rails -v it works great.

@misfo
Copy link
Owner

misfo commented Feb 16, 2012

You must be on a Mac. As you've discovered, your ~/.profile doesn't get sourced for GUI apps. There's a bunch of SO posts about this like this one:
http://stackoverflow.com/questions/135688/setting-environment-variables-in-os-x

I got everything working by setting my path in ~/.MacOSX/environment.plist

@cj
Copy link
Contributor Author

cj commented Feb 16, 2012

Yeep. I know, I got around it by including the path before, but that was for just one off commands. If we add a config option for a command that gets append to the front of everything like: `"cmd_append": "source ~/.profile" so when you run a command it's actually doing:

It will work great and be even more customizable:

@cj
Copy link
Contributor Author

cj commented Feb 16, 2012

Something like this works great:

def exec_cmd(window, cwd, cmd):
    if settings().get('cmd_append'):
        cmd = settings().get('cmd_append') + " && " + cmd
    args = exec_args(cmd)
    args.update({'cmd': cmd, 'shell': True, 'working_dir': cwd})
    window.run_command("exec", args)

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

No branches or pull requests

2 participants