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

gitsh doesn't work on Apple Silicon #384

Open
brandoncordell opened this issue Mar 6, 2021 · 4 comments
Open

gitsh doesn't work on Apple Silicon #384

brandoncordell opened this issue Mar 6, 2021 · 4 comments

Comments

@brandoncordell
Copy link

I just got an M1 MacBook Pro and installed my preferred development tools but I'm not able to get gitsh working.

Here's the error I get when running gitsh:

Traceback (most recent call last):
        5: from /opt/homebrew/Cellar/gitsh/0.14/share/gitsh/ruby/gitsh.rb:6:in `<main>'
        4: from /opt/homebrew/Cellar/gitsh/0.14/share/gitsh/ruby/gitsh.rb:6:in `require'
        3: from /opt/homebrew/Cellar/gitsh/0.14/share/gitsh/ruby/lib/gitsh/environment.rb:3:in `<top (required)>'
        2: from /opt/homebrew/Cellar/gitsh/0.14/share/gitsh/ruby/lib/gitsh/environment.rb:3:in `require'
        1: from /opt/homebrew/Cellar/gitsh/0.14/share/gitsh/ruby/lib/gitsh/line_editor.rb:1:in `<top (required)>'
/opt/homebrew/Cellar/gitsh/0.14/share/gitsh/ruby/lib/gitsh/line_editor.rb:1:in `require': dlopen(/opt/homebrew/Cellar/gitsh/0.14/share/gitsh/ruby/lib/gitsh/line_editor_native.bundle, 0x0009): missing compatible arch in /opt/homebrew/Cellar/gitsh/0.14/share/gitsh/ruby/lib/gitsh/line_editor_native.bundle - /opt/homebrew/Cellar/gitsh/0.14/share/gitsh/ruby/lib/gitsh/line_editor_native.bundle (LoadError)

I also tried running it under the old architecture with arch -x86_64 gitsh and got the following error:

arch: posix_spawnp: gitsh: Bad CPU type in executable

@jjb
Copy link
Contributor

jjb commented Apr 28, 2021

here's what I get trying to build manually

➔ make
depbase=`echo src/gitsh.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
	gcc -DPACKAGE_NAME=\"gitsh\" -DPACKAGE_TARNAME=\"gitsh\" -DPACKAGE_VERSION=\"0.14\" -DPACKAGE_STRING=\"gitsh\ 0.14\" -DPACKAGE_BUGREPORT=\"[email protected]\" -DPACKAGE_URL=\"\" -DPACKAGE=\"gitsh\" -DVERSION=\"0.14\" -I.  -DGITSH_RB_PATH="\"/usr/local/share/gitsh/ruby/gitsh.rb\""   -g -O2 -MT src/gitsh.o -MD -MP -MF $depbase.Tpo -c -o src/gitsh.o src/gitsh.c &&\
	mv -f $depbase.Tpo $depbase.Po
gcc  -g -O2   -o gitsh src/gitsh.o
sed -e 's|@RUBY[@]|/opt/local/bin/ruby|g' -e 's|@rubylibdir[@]|/usr/local/share/gitsh/ruby/lib|g' -e 's|@pkgsysconfdir[@]|/usr/local/etc/gitsh|g' -e 's|@gemsetuppath[@]|/usr/local/share/gitsh/vendor/gems/setup.rb|g' -e 's|@PACKAGE_VERSION[@]|0.14|g' ./src/gitsh.rb.in > src/gitsh.rb
chmod +x src/gitsh.rb
sed -e 's|@RUBY[@]|/opt/local/bin/ruby|g' -e 's|@rubylibdir[@]|/usr/local/share/gitsh/ruby/lib|g' -e 's|@pkgsysconfdir[@]|/usr/local/etc/gitsh|g' -e 's|@gemsetuppath[@]|/usr/local/share/gitsh/vendor/gems/setup.rb|g' -e 's|@PACKAGE_VERSION[@]|0.14|g' ./man/man1/gitsh.1.in > man/man1/gitsh.1
sed -e 's|@RUBY[@]|/opt/local/bin/ruby|g' -e 's|@rubylibdir[@]|/usr/local/share/gitsh/ruby/lib|g' -e 's|@pkgsysconfdir[@]|/usr/local/etc/gitsh|g' -e 's|@gemsetuppath[@]|/usr/local/share/gitsh/vendor/gems/setup.rb|g' -e 's|@PACKAGE_VERSION[@]|0.14|g' ./man/man5/gitsh_completions.5.in > man/man5/gitsh_completions.5
sed -e 's|@RUBY[@]|/opt/local/bin/ruby|g' -e 's|@rubylibdir[@]|/usr/local/share/gitsh/ruby/lib|g' -e 's|@pkgsysconfdir[@]|/usr/local/etc/gitsh|g' -e 's|@gemsetuppath[@]|/usr/local/share/gitsh/vendor/gems/setup.rb|g' -e 's|@PACKAGE_VERSION[@]|0.14|g' ./lib/gitsh/version.rb.in > lib/gitsh/version.rb
cd ext/gitsh && /Library/Developer/CommandLineTools/usr/bin/make
compiling src/line_editor.c
src/line_editor.c:1622:5: warning: incompatible function pointer types passing 'VALUE (VALUE, VALUE)' (aka 'unsigned long (unsigned long, unsigned long)') to parameter of type 'VALUE (*)(VALUE)' (aka 'unsigned long (*)(unsigned long)') [-Wincompatible-function-pointer-types]
    rb_define_singleton_method(mLineEditor, "completer_word_break_characters",
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/local/include/ruby-2.7.0/ruby/intern.h:1218:137: note: expanded from macro 'rb_define_singleton_method'
#define rb_define_singleton_method(klass, mid, func, arity) rb_define_singleton_method_choose_prototypem3((arity),(func))((klass),(mid),(func),(arity));
                                                                                                                                        ^~~~~~
/opt/local/include/ruby-2.7.0/ruby/intern.h:1195:1: note: passing argument to parameter 'func' here
RB_METHOD_DEFINITION_DECL(rb_define_singleton_method, (2,3), (VALUE klass, const char *name), (klass, name))
^
/opt/local/include/ruby-2.7.0/ruby/intern.h:1073:42: note: expanded from macro 'RB_METHOD_DEFINITION_DECL'
RB_METHOD_DEFINITION_DECL_CXX_BEGIN(def) \
                                         ^
/opt/local/include/ruby-2.7.0/ruby/intern.h:1069:5: note: expanded from macro '\
RB_METHOD_DEFINITION_DECL_1'
    RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,funcargs) \
    ^
/opt/local/include/ruby-2.7.0/ruby/intern.h:1042:118: note: expanded from macro 'RB_METHOD_DEFINITION_DECL_C'
    __attribute__((__unused__,__weakref__(#def),__nonnull__ nonnull))static void defname(RB_UNWRAP_MACRO decl,VALUE(*func)funcargs,int arity);
                                                                                                                     ^
src/line_editor.c:1626:5: warning: incompatible function pointer types passing 'VALUE (VALUE, VALUE)' (aka 'unsigned long (unsigned long, unsigned long)') to parameter of type 'VALUE (*)(VALUE)' (aka 'unsigned long (*)(unsigned long)') [-Wincompatible-function-pointer-types]
    rb_define_singleton_method(mLineEditor, "completer_quote_characters",
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/local/include/ruby-2.7.0/ruby/intern.h:1218:137: note: expanded from macro 'rb_define_singleton_method'
#define rb_define_singleton_method(klass, mid, func, arity) rb_define_singleton_method_choose_prototypem3((arity),(func))((klass),(mid),(func),(arity));
                                                                                                                                        ^~~~~~
/opt/local/include/ruby-2.7.0/ruby/intern.h:1195:1: note: passing argument to parameter 'func' here
RB_METHOD_DEFINITION_DECL(rb_define_singleton_method, (2,3), (VALUE klass, const char *name), (klass, name))
^
/opt/local/include/ruby-2.7.0/ruby/intern.h:1073:42: note: expanded from macro 'RB_METHOD_DEFINITION_DECL'
RB_METHOD_DEFINITION_DECL_CXX_BEGIN(def) \
                                         ^
/opt/local/include/ruby-2.7.0/ruby/intern.h:1069:5: note: expanded from macro '\
RB_METHOD_DEFINITION_DECL_1'
    RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,funcargs) \
    ^
/opt/local/include/ruby-2.7.0/ruby/intern.h:1042:118: note: expanded from macro 'RB_METHOD_DEFINITION_DECL_C'
    __attribute__((__unused__,__weakref__(#def),__nonnull__ nonnull))static void defname(RB_UNWRAP_MACRO decl,VALUE(*func)funcargs,int arity);
                                                                                                                     ^
2 warnings generated.
linking shared-object gitsh/line_editor_native.bundle
ld: warning: dylib (/opt/local/lib/libruby.2.7.dylib) was built for newer macOS version (11.2) than being linked (11.0)

@jjb
Copy link
Contributor

jjb commented May 11, 2021

Hm, I'm not sure what changed since the time I tried above, but I tried again with this recipe and it did work 🎉 I do still get the warnings/errors above in the make phase, but they are just warnings i guess, and make install does work (I tried this before in the same way, I swear...) https://gist.github.com/jjb/45c129380e2f344df19b618e1f0075b9

@brandoncordell maybe something analogous will work for you

@brandoncordell
Copy link
Author

Hi @jjb, unfortunately following those steps (using brew at the beginning instead of MacPorts) didn't do much for me. The make step fails outright. I haven't had a ton of time to dig into the failures unfortunately.

@jjb
Copy link
Contributor

jjb commented Nov 17, 2024

something like these steps worked for me: #389 (comment)

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