caldwell / build-emacs

Build scripts for www.emacsformacosx.com
http://www.emacsformacosx.com/about
GNU General Public License v3.0
364 stars 61 forks source link

Launcher should use !#/usr/bin/env ruby instead of !#/usr/bin/ruby #69

Closed dmolesUC closed 2 years ago

dmolesUC commented 6 years ago

Per the Tips And Tricks page, I have a shell script ~/bin/emacs set up to launch Emacs.app in preference to the system emacs:

$ cat ~/bin/emacs 
#!/bin/sh
/Applications/Emacs.app/Contents/MacOS/Emacs "$@"

Every time I launch Emacs from the terminal (either with this script, or directly invoking /Applications/Emacs.app/Contents/MacOS/Emacs) I get something like:

Ignoring binding_of_caller-0.8.0 because its extensions are not built.  Try: gem pristine binding_of_caller --version 0.8.0
Ignoring byebug-10.0.0 because its extensions are not built.  Try: gem pristine byebug --version 10.0.0
Ignoring debase-0.2.2.beta14 because its extensions are not built.  Try: gem pristine debase --version 0.2.2.beta14

This is surprisingly difficult to eradicate with gem pristine; it seems to have something to do with invoking the system Ruby (/usr/bin/ruby) in an environment set up for a different Ruby using rvm or rbenv.

Editing /Applications/Emacs.app/Contents/MacOS/Emacs to replace !#/usr/bin/ruby with !#/usr/bin/env ruby causes the script to correctly use the rvm-configured Ruby on my $PATH, with no errors.

caldwell commented 6 years ago

Hmm. Does env -u RUBYLIB emacs make it work?

I'd almost rather go that route, clearing the extra ruby library paths out and sticking with the system ruby. My thought being that it'd be more consistent—there's less ruby versions to support and it should work even if the locally installed ruby gets borked.

dmolesUC commented 5 years ago

Sorry not to get back to this sooner—I had a reasonable workaround and didn't have a reason to mess with it. But now that I'm setting up a new machine…

I don't have $RUBYLIB in my environment, so env -u RUBYLIB doesn't make a difference. I tried with RUBY_VERSION and MY_RUBY_HOME, but no luck.

My current work around is to use a login shell and rvm use system first:

#!/bin/bash --login
rvm use system && /Applications/Emacs.app/Contents/MacOS/Emacs "$@"

This is clearly an rvm-specific workaround, but it doesn't require modifying the Emacs.app distribution, so I think it's cleaner.

Maybe just a note on the Tips and Tricks page that Emacs.app/Contents/MacOS/Emacs is a Ruby script and Ruby developers may run into some environment problems, with a link to this issue?

23he commented 4 years ago

I'd like to second the initial request to change the first line to

!/usr/bin/env ruby

For some reason system-ruby is quite flakey (i.e. not working) on my 2015 MacBook. Using /usr/bin/env makes all the problems I'm having go away...

dmolesUC commented 4 years ago

@23he FWIW I've switched to emacs-plus, which doesn't get Ruby involved, and have had pretty good luck with it.

caldwell commented 2 years ago

The launcher is no longer written in ruby.