ioquatix / script-runner

This package will run various script files inside of Atom. It currently supports JavaScript, CoffeeScript, Ruby, and Python. You can add more.
http://atom.io/packages/script-runner
Other
62 stars 23 forks source link

Using bad interpreter #39

Closed maasha closed 7 years ago

maasha commented 9 years ago

I would like to run a particular Ruby script using script-runner:

#!/usr/bin/env ruby

require 'biopieces'

p = BP.new.
    read_fastq(first: 100_000, input: 'test_R1.fq.gz', encoding: :base_33).
    run(progress: true)

pp p.status

It works fine from the command line:

/usr/bin/env ruby /Users/maasha/scratch/test.bp

However script-running in atom says:

Script Runner: test.bp

Running: /usr/bin/env ruby /Users/maasha/scratch/test.bp (pgid 2279)
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- biopieces (LoadError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/maasha/scratch/test.bp:3:in `<main>'
Exited with status 1 after 0.065 seconds

It is evidently using the systems Ruby and not the one in the environment as specified by the hash-bang line:

$ env ruby --version
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]
maasha commented 9 years ago

OK, it works if Atom is started from the command line - I suppose that the environment is not loaded correctly if not. Should be documented.

ioquatix commented 9 years ago

It should work.. How do you specify PATH?

maasha commented 9 years ago

I suppose that starting Atom by clicking on the icon in my Mac's Application folder fails to include into the environment stuff installed with Homebrew, i.e. Ruby and hence it falls back to the system one.

ioquatix commented 9 years ago

How is Homebrew setting up the environment? I specifically made script-runner to work in this situation.

ioquatix commented 9 years ago

Specifically, we are using https://github.com/ioquatix/shell-environment to get the shell login environment. It does it by running the following:

$shell -ilc env

e.g.

> zsh -ilc env
TMPDIR=/var/folders/3x/xxxxxxxxxx/T/
XPC_FLAGS=0x0
Apple_PubSub_Socket_Render=/private/tmp/xxxxxxxxx/Render
LANG=en_NZ.UTF-8
DBUS_LAUNCHD_SESSION_BUS_SOCKET=/private/tmp/xxxxxxx/unix_domain_listener
TERM=xterm-256color
SSH_AUTH_SOCK=/private/tmp/xxxxxx/Listeners
SECURITYSESSIONID=xxxxxxxxxx
TERM_PROGRAM=Apple_Terminal
XPC_SERVICE_NAME=0
TERM_PROGRAM_VERSION=343.7
TERM_SESSION_ID=xxxxxxxxxxxxxxxxxx
__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0
SHELL=/opt/local/bin/zsh
HOME=/Users/samuel
LOGNAME=samuel
USER=samuel
PATH=/Users/samuel/.rvm/gems/ruby-2.1.2/bin:/Users/samuel/.rvm/gems/ruby-2.1.2@global/bin:/Users/samuel/.rvm/rubies/ruby-2.1.2/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/samuel/.rvm/gems/ruby-2.1.2/bin:/Users/samuel/.rvm/gems/ruby-2.1.2@global/bin:/Users/samuel/.rvm/rubies/ruby-2.1.2/bin:/opt/local/bin:/opt/local/sbin:/Users/samuel/.rvm/bin:/Users/samuel/.rvm/bin
SHLVL=1
PWD=/Users/samuel
OLDPWD=/Users/samuel
EDITOR=/usr/local/bin/mate -w
ATOM_PATH=/Applications/User
rvm_prefix=/Users/samuel
rvm_path=/Users/samuel/.rvm
rvm_bin_path=/Users/samuel/.rvm/bin
rvm_version=1.26.11 (latest)
GEM_HOME=/Users/samuel/.rvm/gems/ruby-2.1.2
GEM_PATH=/Users/samuel/.rvm/gems/ruby-2.1.2:/Users/samuel/.rvm/gems/ruby-2.1.2@global
MY_RUBY_HOME=/Users/samuel/.rvm/rubies/ruby-2.1.2
IRBRC=/Users/samuel/.rvm/rubies/ruby-2.1.2/.irbrc
RUBY_VERSION=ruby-2.1.2
_=/usr/bin/env
_system_type=Darwin
_system_name=OSX
_system_version=10.10
_system_arch=x86_64
maasha commented 9 years ago

I don't have a shell command, but sh:

 sh -ilc env
TERM_PROGRAM=iTerm.app
TERM=xterm-256color
SHELL=/bin/bash
CLICOLOR=true
TMPDIR=/var/folders/n8/bj0g9xds7b36585b25htych40000gp/T/
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.29tJiE1uYb/Render
PERL5LIB=/Users/maasha/perl5/lib/perl5:/Users/maasha/perl5/lib/perl5::/Users/maasha/biopieces/code_perl:/Users/maasha/biopieces/code_perl
BP_PERL=/Users/maasha/biopieces/code_perl
BP_PYTHON=/Users/maasha/biopieces/code_python
BP_BIN=/Users/maasha/biopieces/bp_bin
PERL_MB_OPT=--install_base "/Users/maasha/perl5"
USER=maasha
BP_WWW=/Users/maasha/biopieces/www
BP_DATA=/Users/maasha/data/BP_DATA
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.0XtCstH8cM/Listeners
__CF_USER_TEXT_ENCODING=0x1F6:0x0:0x0
LSCOLORS=ExFxCxDxBxegedabagacad
BP_TMP=/Users/maasha/scratch/tmp
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/maasha/bin:/Users/maasha/biopieces/bp_bin:/Users/maasha/bin:/Users/maasha/biopieces/bp_bin
BP_LOG=/Users/maasha/BP_LOG
PWD=/Users/maasha/scratch/quiz
BP_DIR=/Users/maasha/biopieces
BP_C=/Users/maasha/biopieces/code_c
ITERM_PROFILE=Default
XPC_FLAGS=0x0
XPC_SERVICE_NAME=0
HISTCONTROL=ignoredups
HOME=/Users/maasha
SHLVL=2
RAILS_ENV=production
ITERM_SESSION_ID=w0t4p0
LOGNAME=maasha
LC_CTYPE=UTF-8
DISPLAY=/private/tmp/com.apple.launchd.yEXZwwmUS7/org.macosforge.xquartz:0
RUBYLIB=:/Users/maasha/install/src/biopieces/lib:/Users/maasha/install/src/gnuplotter/lib:/Users/maasha/install/src/demultiplexer/lib:/Users/maasha/biopieces/code_ruby/lib:/Users/maasha/install/src/biopieces/lib:/Users/maasha/install/src/gnuplotter/lib:/Users/maasha/install/src/demultiplexer/lib:/Users/maasha/biopieces/code_ruby/lib
BP_RUBY=/Users/maasha/biopieces/code_ruby
PERL_MM_OPT=INSTALL_BASE=/Users/maasha/perl5
_=/usr/bin/env
ioquatix commented 9 years ago

I don't see anything in there relating to homebrew.. what is the normal output of env?

maasha commented 9 years ago

I suppose that this is pretty normal env output. My Ruby scripts do use #!/usr/bin/env ruby in the hashbang line, but somehow it looks like the scripts are being executed with /usr/bin/ruby - which I think is from the systems Ruby (/System/Library/Frameworks/Ruby.framework/...).

maasha commented 9 years ago
$ env ruby --version
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]
$ /usr/bin/ruby --version
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
ioquatix commented 9 years ago

I need to see the output of running env in a normal session where ruby is working correctly

maasha commented 9 years ago

That would be identical to the one I first posted:

$ env
TERM_PROGRAM=iTerm.app
SHELL=/bin/bash
TERM=xterm-256color
CLICOLOR=true
TMPDIR=/var/folders/n8/bj0g9xds7b36585b25htych40000gp/T/
PERL5LIB=/Users/maasha/perl5/lib/perl5::/Users/maasha/biopieces/code_perl
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.29tJiE1uYb/Render
BP_PERL=/Users/maasha/biopieces/code_perl
BP_PYTHON=/Users/maasha/biopieces/code_python
BP_BIN=/Users/maasha/biopieces/bp_bin
OLDPWD=/Users/maasha/scratch
PERL_MB_OPT=--install_base "/Users/maasha/perl5"
USER=maasha
BP_WWW=/Users/maasha/biopieces/www
BP_DATA=/Users/maasha/data/BP_DATA
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.0XtCstH8cM/Listeners
__CF_USER_TEXT_ENCODING=0x1F6:0x0:0x0
LSCOLORS=ExFxCxDxBxegedabagacad
BP_TMP=/Users/maasha/scratch/tmp
BP_LOG=/Users/maasha/BP_LOG
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/maasha/bin:/Users/maasha/biopieces/bp_bin
PWD=/Users/maasha/scratch/quiz
BP_DIR=/Users/maasha/biopieces
BP_C=/Users/maasha/biopieces/code_c
ITERM_PROFILE=Default
XPC_FLAGS=0x0
HISTCONTROL=ignoredups
XPC_SERVICE_NAME=0
SHLVL=1
HOME=/Users/maasha
RAILS_ENV=production
ITERM_SESSION_ID=w0t4p0
LOGNAME=maasha
LC_CTYPE=UTF-8
DISPLAY=/private/tmp/com.apple.launchd.yEXZwwmUS7/org.macosforge.xquartz:0
BP_RUBY=/Users/maasha/biopieces/code_ruby
RUBYLIB=:/Users/maasha/install/src/biopieces/lib:/Users/maasha/install/src/gnuplotter/lib:/Users/maasha/install/src/demultiplexer/lib:/Users/maasha/biopieces/code_ruby/lib
PERL_MM_OPT=INSTALL_BASE=/Users/maasha/perl5
_=/usr/bin/env
ioquatix commented 9 years ago

Your path isn't different which is odd:

PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/maasha/bin:/Users/maasha/biopieces/bp_bin:/Users/maasha/bin:/Users/maasha/biopieces/bp_bin
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/maasha/bin:/Users/maasha/biopieces/bp_bin

what does which ruby give you?

maasha commented 9 years ago
$ which ruby
/usr/local/bin/ruby
$ ll /usr/local/bin/ruby
lrwxr-xr-x  1 maasha  admin  29 Jan 21  2015 /usr/local/bin/ruby -> ../Cellar/ruby/2.2.0/bin/ruby
ioquatix commented 9 years ago

So.. I'm pretty confused..

can you run env from within script runner?

maasha commented 9 years ago

How is that done?

maasha commented 9 years ago

Ah,

OK, here is with Atom started from the command line:

TERM_PROGRAM=iTerm.app
TERM=xterm-256color
SHELL=/bin/bash
CLICOLOR=true
TMPDIR=/var/folders/n8/bj0g9xds7b36585b25htych40000gp/T/
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.29tJiE1uYb/Render
PERL5LIB=/Users/maasha/perl5/lib/perl5::/Users/maasha/biopieces/code_perl
BP_PERL=/Users/maasha/biopieces/code_perl
BP_PYTHON=/Users/maasha/biopieces/code_python
BP_BIN=/Users/maasha/biopieces/bp_bin
PERL_MB_OPT=--install_base "/Users/maasha/perl5"
ATOM_HOME=/Users/maasha/.atom
USER=maasha
BP_WWW=/Users/maasha/biopieces/www
BP_DATA=/Users/maasha/data/BP_DATA
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.0XtCstH8cM/Listeners
__CF_USER_TEXT_ENCODING=0x1F6:0x0:0x0
LSCOLORS=ExFxCxDxBxegedabagacad
GOOGLE_API_KEY=AIzaSyAQfxPJiounkhOjODEO5ZieffeBv6yft2Q
BP_TMP=/Users/maasha/scratch/tmp
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/maasha/bin:/Users/maasha/biopieces/bp_bin
BP_LOG=/Users/maasha/BP_LOG
_=/usr/bin/env
PWD=/
BP_DIR=/Users/maasha/biopieces
BP_C=/Users/maasha/biopieces/code_c
ITERM_PROFILE=Default
NODE_PATH=/Applications/Atom.app/Contents/Resources/app.asar/exports
XPC_FLAGS=0x0
NODE_ENV=production
HISTCONTROL=ignoredups
XPC_SERVICE_NAME=0
SHLVL=3
HOME=/Users/maasha
RAILS_ENV=production
ITERM_SESSION_ID=w0t2p0
LOGNAME=maasha
LC_CTYPE=UTF-8
DISPLAY=/private/tmp/com.apple.launchd.yEXZwwmUS7/org.macosforge.xquartz:0
RUBYLIB=:/Users/maasha/install/src/biopieces/lib:/Users/maasha/install/src/gnuplotter/lib:/Users/maasha/install/src/demultiplexer/lib:/Users/maasha/biopieces/code_ruby/lib
BP_RUBY=/Users/maasha/biopieces/code_ruby
PERL_MM_OPT=INSTALL_BASE=/Users/maasha/perl5
Exited with status 0 after 0.091 seconds

And here is env with Atom started by clicking the Atom icon:

SHELL=/bin/bash
TMPDIR=/var/folders/n8/bj0g9xds7b36585b25htych40000gp/T/
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.29tJiE1uYb/Render
ATOM_HOME=/Users/maasha/.atom
USER=maasha
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.0XtCstH8cM/Listeners
__CF_USER_TEXT_ENCODING=0x1F6:0x0:0x0
GOOGLE_API_KEY=AIzaSyAQfxPJiounkhOjODEO5ZieffeBv6yft2Q
PATH=/usr/bin:/bin:/usr/sbin:/sbin
VERSIONER_PYTHON_VERSION=2.7
PWD=/
NODE_PATH=/Applications/Atom.app/Contents/Resources/app.asar/exports
XPC_FLAGS=0x0
NODE_ENV=production
XPC_SERVICE_NAME=0
SHLVL=1
HOME=/Users/maasha
LOGNAME=maasha
VERSIONER_PYTHON_PREFER_32_BIT=no
DISPLAY=/private/tmp/com.apple.launchd.yEXZwwmUS7/org.macosforge.xquartz:0
_=/usr/bin/env

Clearly a difference ...

ioquatix commented 9 years ago

What version of script runner are you using? the latest?

maasha commented 9 years ago

1.8.3

ioquatix commented 9 years ago

Basically, there must be something wrong with how https://github.com/ioquatix/shell-environment is working.. can you see if there are any errors in atom's console, e.g.

"child process failed with ..." or "child process exited with non-zero status ..."

maasha commented 9 years ago

Nope, nothing there. Maybe simply mention in the documentation that Atom should be started from the command line in order to load the full environment (I saw some other Atom package that did so)?

ioquatix commented 9 years ago

shell-environment is deliberately designed to alleviate the issue you are having but clearly something is not working. It loads the environment from the login shell. But if this fails, it will use process.env which looks like the behaviour you are experiencing. I'd like to know why shell-environment is failing so it can be fixed.

Probably the easiest way to do that is to run this script INSIDE atom launched from the sidebar/clicking the atom icon: https://github.com/ioquatix/script-runner/blob/master/examples/shell-environment.coffee

Please tell me the results.

maasha commented 9 years ago

Catch 22

env: coffee: No such file or directory

I installed coffee with

$ npm install -g coffee-script

npm was installed via homebrew ...

ioquatix commented 9 years ago

haha - you could always use a full path.

maasha commented 9 years ago

sigh

then:

env: node: No such file or directory

And this I can't really get to hard code ...

On Thu, Aug 20, 2015 at 4:12 PM, Samuel Williams notifications@github.com wrote:

haha - you could always use a full path.

— Reply to this email directly or view it on GitHub https://github.com/ioquatix/script-runner/issues/39#issuecomment-133024540 .

ioquatix commented 9 years ago

can you firstly try running when you launch atom from the command line, let me know the output.

ioquatix commented 9 years ago

in theory you can also write

!/usr/bin/env PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/maasha/bin:/Users/maasha/biopieces/bp_bin coffee

it should work.

maasha commented 9 years ago
Script Runner: untitled

Running: /usr/bin/env coffee (pgid 87446)
GJcoffee> G#!/usr/bin/env coffee

undefined
GJcoffee> G

undefined
GJcoffee> GShellEnvironment = require 'shell-environment'

module.js:338
    throw err;
          ^
Error: Cannot find module 'shell-environment'
  at Function.Module._resolveFilename (module.js:336:15)
  at Function.Module._load (module.js:278:25)
  at Module.require (module.js:365:17)
  at require (module.js:384:17)
  at repl:3:24
  at Object.exports.runInThisContext (vm.js:74:17)
  at runInContext (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:57:17)
  at REPLServer.replDefaults.eval (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:46:25)
  at bound (domain.js:254:14)
  at REPLServer.runBound [as eval] (domain.js:267:12)
  at repl.js:279:12
  at REPLServer.<anonymous> (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:86:9)
  at REPLServer.emit (events.js:129:20)
  at REPLServer.Interface._onLine (readline.js:214:10)
  at REPLServer.Interface._line (readline.js:553:8)
  at REPLServer.Interface._ttyWrite (readline.js:837:16)
  at Socket.onkeypress (readline.js:109:10)
  at Socket.emit (events.js:129:20)
  at readline.js:1175:14
  at Array.forEach (native)
  at emitKeys (readline.js:993:10)
  at Socket.onData (readline.js:910:14)
  at Socket.emit (events.js:107:17)
  at readableAddChunk (_stream_readable.js:163:16)
  at Socket.Readable.push (_stream_readable.js:126:10)
  at Pipe.onread (net.js:538:20)

GJcoffee> GGJcoffee> G

undefined
GJcoffee> GShellEnvironment.loginEnvironment (error, environment) =>

repl:1
_ = ShellEnvironment.loginEnvironment((function(_this) {
                    ^
TypeError: Cannot read property 'loginEnvironment' of undefined
  at repl:1:21
  at Object.exports.runInThisContext (vm.js:74:17)
  at runInContext (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:57:17)
  at REPLServer.replDefaults.eval (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:46:25)
  at bound (domain.js:254:14)
  at REPLServer.runBound [as eval] (domain.js:267:12)
  at repl.js:279:12
  at REPLServer.<anonymous> (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:86:9)
  at REPLServer.emit (events.js:129:20)
  at REPLServer.Interface._onLine (readline.js:214:10)
  at REPLServer.Interface._line (readline.js:553:8)
  at REPLServer.Interface._ttyWrite (readline.js:837:16)
  at Socket.onkeypress (readline.js:109:10)
  at Socket.emit (events.js:129:20)
  at readline.js:1175:14
  at Array.forEach (native)
  at emitKeys (readline.js:993:10)
  at Socket.onData (readline.js:910:14)
  at Socket.emit (events.js:107:17)
  at readableAddChunk (_stream_readable.js:163:16)
  at Socket.Readable.push (_stream_readable.js:126:10)
  at Pipe.onread (net.js:538:20)

GJcoffee> GGJcoffee> G    if environment

[stdin]:1:1: error: unexpected if
if environment
^^
GJcoffee> GGJcoffee> G        console.log(environment)

repl:1
_ = console.log(environment);
                ^
ReferenceError: environment is not defined
  at repl:1:17
  at Object.exports.runInThisContext (vm.js:74:17)
  at runInContext (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:57:17)
  at REPLServer.replDefaults.eval (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:46:25)
  at bound (domain.js:254:14)
  at REPLServer.runBound [as eval] (domain.js:267:12)
  at repl.js:279:12
  at REPLServer.<anonymous> (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:86:9)
  at REPLServer.emit (events.js:129:20)
  at REPLServer.Interface._onLine (readline.js:214:10)
  at REPLServer.Interface._line (readline.js:553:8)
  at REPLServer.Interface._ttyWrite (readline.js:837:16)
  at Socket.onkeypress (readline.js:109:10)
  at Socket.emit (events.js:129:20)
  at readline.js:1175:14
  at Array.forEach (native)
  at emitKeys (readline.js:993:10)
  at Socket.onData (readline.js:910:14)
  at Socket.emit (events.js:107:17)
  at readableAddChunk (_stream_readable.js:163:16)
  at Socket.Readable.push (_stream_readable.js:126:10)
  at Pipe.onread (net.js:538:20)

GJcoffee> GGJcoffee> G    else

[stdin]:1:1: error: unexpected else
else
^^^^
GJcoffee> GGJcoffee> G        console.log(error)repl:1
_ = console.log(error);
                ^
ReferenceError: error is not defined
  at repl:1:17
  at Object.exports.runInThisContext (vm.js:74:17)
  at runInContext (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:57:17)
  at REPLServer.replDefaults.eval (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:46:25)
  at bound (domain.js:254:14)
  at REPLServer.runBound [as eval] (domain.js:267:12)
  at repl.js:279:12
  at REPLServer.<anonymous> (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:86:9)
  at REPLServer.emit (events.js:129:20)
  at Socket.ontermend (readline.js:103:12)
  at Socket.emit (events.js:129:20)
  at _stream_readable.js:908:16
  at process._tickDomainCallback (node.js:381:11)

GJcoffee>         console.log(error)GGJcoffee>         console.log(error)G
ioquatix commented 9 years ago

Does the following show stuff for you?

> ls ~/.atom/packages/script-runner/node_modules/shell-environment
README.md   lib     package.json    test
ioquatix commented 9 years ago

maybe try sudo npm install -g shell-environment

maasha commented 9 years ago

So it seems

$ ll ~/.atom/packages/script-runner/node_modules/shell-environment
total 16
drwxr-xr-x  6 maasha  staff   204 Aug 12 13:06 .
drwxr-xr-x  6 maasha  staff   204 Aug 12 13:06 ..
-rw-r--r--  1 maasha  staff  2185 Aug 12 13:06 README.md
drwxr-xr-x  4 maasha  staff   136 Aug 12 13:06 lib
-rw-r--r--  1 maasha  staff  1647 Aug 12 13:06 package.json
drwxr-xr-x  3 maasha  staff   102 Aug 12 13:06 test
maasha commented 9 years ago

I'd rather not install stuff as root. The point of homebrew is not to.

ioquatix commented 9 years ago

You are installing homebrew into /usr/local/bin/.. doesn't that already require sudo?

ioquatix commented 9 years ago

use #!/usr/bin/env PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/maasha/bin:/Users/maasha/biopieces/bp_bin coffee to run the script as the first line

maasha commented 9 years ago
Script Runner: untitled

Running: /usr/bin/env PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/maasha/bin:/Users/maasha/biopieces/bp_bin coffee (pgid 87602)
GJcoffee> G#!/usr/bin/env PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/maasha/bin:/Users/maasha/biopieces/bp_bin coffee

undefined
GJcoffee> G

undefined
GJcoffee> GShellEnvironment = require 'shell-environment'

module.js:338
    throw err;
          ^
Error: Cannot find module 'shell-environment'
  at Function.Module._resolveFilename (module.js:336:15)
  at Function.Module._load (module.js:278:25)
  at Module.require (module.js:365:17)
  at require (module.js:384:17)
  at repl:3:24
  at Object.exports.runInThisContext (vm.js:74:17)
  at runInContext (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:57:17)
  at REPLServer.replDefaults.eval (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:46:25)
  at bound (domain.js:254:14)
  at REPLServer.runBound [as eval] (domain.js:267:12)
  at repl.js:279:12
  at REPLServer.<anonymous> (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:86:9)
  at REPLServer.emit (events.js:129:20)
  at REPLServer.Interface._onLine (readline.js:214:10)
  at REPLServer.Interface._line (readline.js:553:8)
  at REPLServer.Interface._ttyWrite (readline.js:837:16)
  at Socket.onkeypress (readline.js:109:10)
  at Socket.emit (events.js:129:20)
  at readline.js:1175:14
  at Array.forEach (native)
  at emitKeys (readline.js:993:10)
  at Socket.onData (readline.js:910:14)
  at Socket.emit (events.js:107:17)
  at readableAddChunk (_stream_readable.js:163:16)
  at Socket.Readable.push (_stream_readable.js:126:10)
  at Pipe.onread (net.js:538:20)

GJcoffee> GGJcoffee> G

undefined
GJcoffee> GShellEnvironment.loginEnvironment (error, environment) =>

repl:1
_ = ShellEnvironment.loginEnvironment((function(_this) {
                    ^
TypeError: Cannot read property 'loginEnvironment' of undefined
  at repl:1:21
  at Object.exports.runInThisContext (vm.js:74:17)
  at runInContext (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:57:17)
  at REPLServer.replDefaults.eval (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:46:25)
  at bound (domain.js:254:14)
  at REPLServer.runBound [as eval] (domain.js:267:12)
  at repl.js:279:12
  at REPLServer.<anonymous> (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:86:9)
  at REPLServer.emit (events.js:129:20)
  at REPLServer.Interface._onLine (readline.js:214:10)
  at REPLServer.Interface._line (readline.js:553:8)
  at REPLServer.Interface._ttyWrite (readline.js:837:16)
  at Socket.onkeypress (readline.js:109:10)
  at Socket.emit (events.js:129:20)
  at readline.js:1175:14
  at Array.forEach (native)
  at emitKeys (readline.js:993:10)
  at Socket.onData (readline.js:910:14)
  at Socket.emit (events.js:107:17)
  at readableAddChunk (_stream_readable.js:163:16)
  at Socket.Readable.push (_stream_readable.js:126:10)
  at Pipe.onread (net.js:538:20)

GJcoffee> GGJcoffee> G    if environment

[stdin]:1:1: error: unexpected if
if environment
^^
GJcoffee> GGJcoffee> G        console.log(environment)

repl:1
_ = console.log(environment);
                ^
ReferenceError: environment is not defined
  at repl:1:17
  at Object.exports.runInThisContext (vm.js:74:17)
  at runInContext (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:57:17)
  at REPLServer.replDefaults.eval (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:46:25)
  at bound (domain.js:254:14)
  at REPLServer.runBound [as eval] (domain.js:267:12)
  at repl.js:279:12
  at REPLServer.<anonymous> (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:86:9)
  at REPLServer.emit (events.js:129:20)
  at REPLServer.Interface._onLine (readline.js:214:10)
  at REPLServer.Interface._line (readline.js:553:8)
  at REPLServer.Interface._ttyWrite (readline.js:837:16)
  at Socket.onkeypress (readline.js:109:10)
  at Socket.emit (events.js:129:20)
  at readline.js:1175:14
  at Array.forEach (native)
  at emitKeys (readline.js:993:10)
  at Socket.onData (readline.js:910:14)
  at Socket.emit (events.js:107:17)
  at readableAddChunk (_stream_readable.js:163:16)
  at Socket.Readable.push (_stream_readable.js:126:10)
  at Pipe.onread (net.js:538:20)

GJcoffee> GGJcoffee> G    else

[stdin]:1:1: error: unexpected else
else
^^^^
GJcoffee> GGJcoffee> G        console.log(error)repl:1
_ = console.log(error);
                ^
ReferenceError: error is not defined
  at repl:1:17
  at Object.exports.runInThisContext (vm.js:74:17)
  at runInContext (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:57:17)
  at REPLServer.replDefaults.eval (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:46:25)
  at bound (domain.js:254:14)
  at REPLServer.runBound [as eval] (domain.js:267:12)
  at repl.js:279:12
  at REPLServer.<anonymous> (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:86:9)
  at REPLServer.emit (events.js:129:20)
  at Socket.ontermend (readline.js:103:12)
  at Socket.emit (events.js:129:20)
  at _stream_readable.js:908:16
  at process._tickDomainCallback (node.js:381:11)

GJcoffee>         console.log(error)GGJcoffee>         console.log(error)G
ioquatix commented 9 years ago

I guess you will need to install it in order to run it then, sorry I'm not a super npm guru.

maasha commented 9 years ago

This is a pesky problem. Shall we let it rest until someone else reports the same issue?

On Thu, Aug 20, 2015 at 4:42 PM, Samuel Williams notifications@github.com wrote:

I guess you will need to install it in order to run it then, sorry I'm not a super npm guru.

— Reply to this email directly or view it on GitHub https://github.com/ioquatix/script-runner/issues/39#issuecomment-133035843 .

ioquatix commented 9 years ago

Sure but if there is a bug with shell-environment I'd like to know about it.

ioquatix commented 7 years ago

Just touching on this issue, did you ever find a satisfactory solution?

maasha commented 7 years ago

Nope. I start atom from the command line as a habit now.

ioquatix commented 7 years ago

@maasha We've just released 2.0.0 would you mind testing again?

maasha commented 7 years ago

Seems to be working, yay!

ioquatix commented 7 years ago

Awesome :)