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

On OSX, need to remove #! /bin/sh from th? #32

Open
hughperkins opened this issue Sep 26, 2015 · 10 comments
Open

On OSX, need to remove #! /bin/sh from th? #32

hughperkins opened this issue Sep 26, 2015 · 10 comments

Comments

@hughperkins
Copy link

On OSX, need to remove #! /bin/sh from th?

See here:

hughperkins/cltorch#21 (comment)

@soumith
Copy link
Member

soumith commented Oct 4, 2015

@hughperkins which file are you referring to? I dont see any file under the trepl repo itself having that shebang.

@hughperkins
Copy link
Author

I'm not sure what the source file is, but I just double-checked that installing via distro does create such a file. You can try:

cd
mv torch torch_  # just to get it out of the way, temporarily
git clone https://github.com/torch/distro.git torch2
cd torch2
./install.sh
cat ~/torch2/install/bin/th  # result below
cd
rm -Rf torch2   # clean up
mv torch_ torch  # put it back again

Result of cat ~/torch2/install/bin/th:

#!/bin/sh

exec '/home/ubuntu/torch2/install/bin/luajit' -e 'package.path="/home/ubuntu/.luarocks/share/lua/5.1/?.lua;/home/ubuntu/.luarocks/share/lua/5.1/?/init.lua;/home/ubuntu/torch2/install/share/lua/5.1/?.lua;/home/ubuntu/torch2/install/share/lua/5.1/?/init.lua;"..package.path; package.cpath="/home/ubuntu/.luarocks/lib/lua/5.1/?.so;/home/ubuntu/torch2/install/lib/lua/5.1/?.so;"..package.cpath' -e 'local k,l,_=pcall(require,"luarocks.loader") _=k and l.add_context("trepl","scm-1")' '/home/ubuntu/torch2/install/lib/luarocks/rocks/trepl/scm-1/bin/th' "$@"

You can see that the first line is #!/bin/sh

@hughperkins
Copy link
Author

Odd right? Because the th in trepl is totally different :-P Much longer.

@hughperkins
Copy link
Author

I think it'd need someone to go through install.sh line by line, running each line manually, and testing for ~/torch/install/bin/th at each step, so we can find out what creates it :-)

@soumith
Copy link
Member

soumith commented Oct 7, 2015

ohhh, i think this is because of some luarocks over-smartness. If you use the "builtin" build system, and specifiy something in the "bin" section, it auto-wraps it in such shell scripts I believe:
https://github.com/torch/trepl/blob/master/trepl-scm-1.rockspec#L48-L51

@hughperkins
Copy link
Author

Ok. So... what needs to be changed so that the environment for users on Mac OS X loads correctly?

@spdustin
Copy link

unix.wrap_script is getting called and adding it. Maybe the config for osx/darwin could include wrap_bin_scripts: false in the rock spec.

@hughperkins
Copy link
Author

@spdustin ok, you mean, this is something I can modify in the cltorch rockspec somehow?

@hughperkins
Copy link
Author

So, could it be something like, put just before/after line 57 https://github.com/keplerproject/luarocks/blob/e3203adbc3f5daa5f46097d3439edbada01807f3/src/luarocks/fs/unix.lua#L57 :

local ffi = require('ffi')
if ffi.os ~= 'Mac' then   -- not sure what this value will be on Mac, but conceptually I mean
    wrapper:write("#!/bin/sh\n\n")
end

@hughperkins
Copy link
Author

Per hughperkins/cltorch#24 (comment) , the appropriate comparison string is 'OSX', so it would look like:

local ffi = require('ffi')
if ffi.os ~= 'OSX' then
    wrapper:write("#!/bin/sh\n\n")
end

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

3 participants