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

Error loading r18n-desktop: uninitialized constant Psych::Syck::PrivateType #443

Open
apjanke opened this issue May 27, 2019 · 11 comments
Open

Comments

@apjanke
Copy link

apjanke commented May 27, 2019

I'm running Shoes 3.3.7 r3301 on macOS 10.14.5. I'm trying to use the r18n-desktop gem in my Shoes app.

My app:

Shoes.setup do
  gem "r18n-desktop"
end

require "r18n-desktop"

Shoes.app do
  button "Push me"
end

But I get an error when it does that require "r18n-desktop".

Warn in <unknown> line 0 | 2019-05-27 09:29:14 -0400
Ignoring jaro_winkler-1.3.7 because its extensions are not built.  Try: gem pristine jaro_winkler --version 1.3.7

Error in <unknown> line 0 | 2019-05-27 09:29:20 -0400
uninitialized constant Psych::Syck::PrivateType
Did you mean?  Psych::PrivateType

Screen Shot 2019-05-27 at 9 30 37 AM

The r18n-desktop gem installs and loads fine on my system and Homebrewed Rubys.

Any idea what's going on here? Googling hasn't helped me.

@apjanke
Copy link
Author

apjanke commented May 27, 2019

Same error under Shoes 3.3.8 beta r3350.

@ccoupe
Copy link

ccoupe commented May 27, 2019

Hi, @apjanke . Native gems are troublesome. Shoes has it's own Ruby and doesn't use the one installed by Apple or one you might have installed with homebrew or with RVM/RbEnv. Shoes also has it's own gem repository on disk AND Shoes has it's own gem code (borrowed of course). From the command line (OSX): $ /cshoes -g env, and ./cshoes --gem install r18n-desktop` and Shoes has Cobbler (the maintain Shoes screen) for managing gems graphically. Like all gem installs that compile, there will be a log file with the errors to correct. The command line is the best way to get that location.

Start shoes -> Maintain shoes -> Gems->Manage->Show Local. There is a Cobbler menu item to create the `cshoes' bash script for your installation of Shoes.

@ccoupe
Copy link

ccoupe commented May 27, 2019

ccoupe@mini:~/Projects/shoes3$ ./cshoes -g install jaro_winkler --no-doc 
ruby is /Users/ccoupe/build/yosemite/Shoes.app/Contents/MacOS/shoes-bin --ruby
Fetching jaro_winkler-1.5.2.gem
Building native extensions. This could take a while...
Successfully installed jaro_winkler-1.5.2
1 gem installed
Exiting RubyGems with exit_code 0
ccoupe@mini:~/Projects/shoes3$ 

Seems OK. Note the version is much different from yours.

ccoupe@mini:~/Projects/shoes3$ ./cshoes -g install r18n-desktop --no-doc 
ruby is /Users/ccoupe/build/yosemite/Shoes.app/Contents/MacOS/shoes-bin --ruby
Fetching r18n-desktop-3.2.0.gem
Fetching r18n-core-3.2.0.gem
Successfully installed r18n-core-3.2.0
Successfully installed r18n-desktop-3.2.0
2 gems installed
Exiting RubyGems with exit_code 0
ccoupe@mini:~/Projects/shoes3$ 

@apjanke
Copy link
Author

apjanke commented May 27, 2019

Hmm. I'm afraid that it's not working for me. This is with Shoes 3.3.8 beta r3371 on macOS 10.14.5 with Xcode 10.2.1. I created a cshoes script successfully with that version of Shoes.

[~]
$ which cshoes
/Users/janke/local/bin/cshoes
[~]
$ cshoes -v
Shoes walkabout 3.3.8 r3371 x86_64-darwin14 2.4.6
[~]
$ cshoes -g install jaro_winkler --no-doc
ruby is /Applications/Shoes.app/Contents/MacOS/shoes-bin --ruby
Fetching jaro_winkler-1.5.2.gem
Building native extensions. This could take a while...
ERROR:  Error installing jaro_winkler:
	ERROR: Failed to build gem native extension.

    current directory: /Applications/Shoes.app/Contents/MacOS/lib/ruby/gems/2.4.0/gems/jaro_winkler-1.5.2/ext/jaro_winkler
/Applications/Shoes.app/Contents/MacOS/shoes-bin --ruby -I /Applications/Shoes.app/Contents/MacOS/lib/ruby/site_ruby/2.4.0 -r ./siteconf20190527-11320-1uycehw.rb extconf.rb
creating Makefile

current directory: /Applications/Shoes.app/Contents/MacOS/lib/ruby/gems/2.4.0/gems/jaro_winkler-1.5.2/ext/jaro_winkler
make "DESTDIR=" clean
rm -f
rm -f jaro_winkler_ext.bundle  *.o  *.bak mkmf.log .*.time

current directory: /Applications/Shoes.app/Contents/MacOS/lib/ruby/gems/2.4.0/gems/jaro_winkler-1.5.2/ext/jaro_winkler
make "DESTDIR="
clang -I. -I/Applications/Shoes.app/Contents/MacOS/lib/ruby/include/ruby-2.4.0/x86_64-darwin14 -I/Applications/Shoes.app/Contents/MacOS/lib/ruby/include/ruby-2.4.0/ruby/backward -I/Applications/Shoes.app/Contents/MacOS/lib/ruby/include/ruby-2.4.0 -I. -mmacosx-version-min=10.10 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -I/Users/ccoupe/shoesdeps/10.10-2/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -fno-common -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens  -fno-common -pipe -std=c99  -mmacosx-version-min=10.10  -o adj_matrix.o -c adj_matrix.c
clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk' [-Wmissing-sysroot]
In file included from adj_matrix.c:2:
In file included from ./codepoints.h:2:
In file included from /Applications/Shoes.app/Contents/MacOS/lib/ruby/include/ruby-2.4.0/ruby.h:33:
In file included from /Applications/Shoes.app/Contents/MacOS/lib/ruby/include/ruby-2.4.0/ruby/ruby.h:36:
/Applications/Shoes.app/Contents/MacOS/lib/ruby/include/ruby-2.4.0/ruby/defines.h:101:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^~~~~~~~~
1 error generated.
make: *** [adj_matrix.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Applications/Shoes.app/Contents/MacOS/lib/ruby/gems/2.4.0/gems/jaro_winkler-1.5.2 for inspection.
Results logged to /Applications/Shoes.app/Contents/MacOS/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-14/2.4.0/jaro_winkler-1.5.2/gem_make.out
Exiting RubyGems with exit_code 1
[~]
$

Seems like it's looking for the wrong MacOSX SDK, and looking for Xcode in the wrong place.

clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk' [-Wmissing-sysroot]

I have Xcode installed as /Applications/Xcode-10.2.1.app instead of /Applications/Xcode.app. My xcode-select is set up to point there.

$ ls -ld /Applications/Xcode*
drwxr-xr-x  3 janke  staff  96 Apr  5 20:33 /Applications/Xcode-10.2.1.app
$ xcode-select -p
/Applications/Xcode-10.2.1.app/Contents/Developer

Moving Xcode back to its default installation location didn't fix it. Same issue. I suspect this time it's just the SDK version that's wrong.

[~]
$ ls -ld /Applications/Xcode*
drwxr-xr-x  3 janke  staff  96 Apr  5 20:33 /Applications/Xcode.app
[~]
$ xcode-select -p
/Applications/Xcode.app/Contents/Developer
[~]
$ cshoes -g install jaro_winkler --no-doc
ruby is /Applications/Shoes.app/Contents/MacOS/shoes-bin --ruby
Building native extensions. This could take a while...
ERROR:  Error installing jaro_winkler:
	ERROR: Failed to build gem native extension.

    current directory: /Applications/Shoes.app/Contents/MacOS/lib/ruby/gems/2.4.0/gems/jaro_winkler-1.5.2/ext/jaro_winkler
/Applications/Shoes.app/Contents/MacOS/shoes-bin --ruby -I /Applications/Shoes.app/Contents/MacOS/lib/ruby/site_ruby/2.4.0 -r ./siteconf20190527-11823-188427c.rb extconf.rb
creating Makefile

current directory: /Applications/Shoes.app/Contents/MacOS/lib/ruby/gems/2.4.0/gems/jaro_winkler-1.5.2/ext/jaro_winkler
make "DESTDIR=" clean
rm -f
rm -f jaro_winkler_ext.bundle  *.o  *.bak mkmf.log .*.time

current directory: /Applications/Shoes.app/Contents/MacOS/lib/ruby/gems/2.4.0/gems/jaro_winkler-1.5.2/ext/jaro_winkler
make "DESTDIR="
clang -I. -I/Applications/Shoes.app/Contents/MacOS/lib/ruby/include/ruby-2.4.0/x86_64-darwin14 -I/Applications/Shoes.app/Contents/MacOS/lib/ruby/include/ruby-2.4.0/ruby/backward -I/Applications/Shoes.app/Contents/MacOS/lib/ruby/include/ruby-2.4.0 -I. -mmacosx-version-min=10.10 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -I/Users/ccoupe/shoesdeps/10.10-2/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -fno-common -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens  -fno-common -pipe -std=c99  -mmacosx-version-min=10.10  -o adj_matrix.o -c adj_matrix.c
clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk' [-Wmissing-sysroot]
In file included from adj_matrix.c:2:
In file included from ./codepoints.h:2:
In file included from /Applications/Shoes.app/Contents/MacOS/lib/ruby/include/ruby-2.4.0/ruby.h:33:
In file included from /Applications/Shoes.app/Contents/MacOS/lib/ruby/include/ruby-2.4.0/ruby/ruby.h:36:
/Applications/Shoes.app/Contents/MacOS/lib/ruby/include/ruby-2.4.0/ruby/defines.h:101:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^~~~~~~~~
1 error generated.
make: *** [adj_matrix.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Applications/Shoes.app/Contents/MacOS/lib/ruby/gems/2.4.0/gems/jaro_winkler-1.5.2 for inspection.
Results logged to /Applications/Shoes.app/Contents/MacOS/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-14/2.4.0/jaro_winkler-1.5.2/gem_make.out
Exiting RubyGems with exit_code 1
[~]
$

That gem_make.out file just contains the same messages.

Maybe Shoes is getting built so it has a dependency on the specific MacOSX SDK version in the Xcode installed on the machine it is built on?

@ccoupe
Copy link

ccoupe commented May 28, 2019

Maybe Shoes is getting built so it has a dependency on the specific MacOSX SDK version in the Xcode installed on the machine it is built on?

Sad but true. Shoes is built against 10.10 (or 10.11) SDK. (and darwin-14) I have to build against some version of the SDK and that choice will be wrong for some folks. Sigh. You can get a copy of the SDK and symlink it into where Xcode wants them - that's what I do - I'm running 10.13.5 (I think). Beware - new update versions of xcode will wipe out older SDK so use a symlink inside xcode. I don't have a handy link to where the 10.10 SDK can be found. I know you can find them in the Vagrant image

@ccoupe
Copy link

ccoupe commented May 28, 2019

I've uploaded a tar ball with jaro-winkler, r18n-desktop and rmagick built by and for shoes 3.3.8. That will get you going but doesn't solve the real issue. To use, copy the tgz to your home dir .shoes and untar it. Of course you can look inside before untaring with a tar ztf shoes-osx-gems.tgz.

mv ~/Downloads/shoes-osx-gems.tgz ~/.shoes
cd  ~/.shoes
tar tf shoes-osx-gems.tgz
tar xf shoes-osx-gems.tgz

@apjanke
Copy link
Author

apjanke commented May 28, 2019

I think the native gem issue might be a red herring here. I've found that I'm getting the same problem if I require just r18n-core, which as far as I can tell has no native extensions.

load_r18n_core.rb:

Shoes.setup do
  gem "r18n-core"
end

require "r18n-core"

Shoes.app do
  button "Push me"
end

Under Shoes 3.3.7:

Screen Shot 2019-05-27 at 11 51 06 PM

Under Shoes 3.3.8 beta r3371:

Screen Shot 2019-05-27 at 11 51 43 PM

This is with a fresh ~/.shoes (done via rm -rf ~/.shoes/*) for each run.

I've also reported it to the r18n crew to see if they know what might be going on: r18n/r18n#210.

It's rather confusing to me that it's looking for Psych::Syck::PrivateType when the code is just referencing ::Syck::PrivateType, which ought to be looking for Syck in the global namespace, right?

@apjanke
Copy link
Author

apjanke commented May 28, 2019

Okay, here's another weird thing.

I got rid of the jaro_winkler editor by doing /usr/bin/gem uninstall jaro_winkler. That jaro_winkler gem was in my ~/.gem directory, installed via another Ruby a long time ago; I don't even remember why.

Now, the "uninitialized constant Psych::Syck::PrivateType" error is only happening on the first run of my app after doing rm -rf ~/.shoes/*. If I quit out of Shoes after the error pops up, re-open it, and re-run my app, it runs fine: there's no error message, and the "Push me" button appears. So it seems something in the gem installation process itself is causing this?

@ccoupe
Copy link

ccoupe commented May 28, 2019

More likely is Shoes gem handling is getting confused about gem locations. This (was?) a problem with rvm installed rubies - or possibly any ruby in it's PATH but really the setting of GEM_HOME could be bleeding into Shoes. I thought 3.3.8 fixed that but ? For the manual->furthermore->samples - run simple info.rb which displays the ENV vars and load paths.

I've got a better fix for the gem building if you want to try it out. Edit Shoes.app/Contents/MacOS/lib/setup.rb line 22 so it looks like:

	    mf = mf.gsub(/^ARCH_FLAG =/, "ARCH_FLAG = #{RbConfig::CONFIG['ARCH_FLAG']}")
	    mf = mf.gsub(/MacOSX10\.\d+\.sdk/, 'MacOSX.sdk')
	    #mf = mf.gsub(/^INSTALL\s*=\s*.*$/, "INSTALL = $(RUBY) -run -e install -- -vp")

@apjanke
Copy link
Author

apjanke commented May 28, 2019

I tried your patch against 3.3.8 r3371 beta, and it's happy installing stuff with native extensions now:

$ which cshoes
/Users/janke/local/bin/cshoes
[~]
$ cshoes -v
Shoes walkabout 3.3.8 r3371 x86_64-darwin14 2.4.6
[~]
$ cshoes -g install jaro_winkler --no-doc
ruby is /Applications/Shoes.app/Contents/MacOS/shoes-bin --ruby
Building native extensions. This could take a while...
Successfully installed jaro_winkler-1.5.2
1 gem installed
Exiting RubyGems with exit_code 0
[~]
$ cshoes -g install r18n-desktop --no-doc
ruby is /Applications/Shoes.app/Contents/MacOS/shoes-bin --ruby
Fetching r18n-desktop-3.2.0.gem
Fetching r18n-core-3.2.0.gem
Successfully installed r18n-core-3.2.0
Successfully installed r18n-desktop-3.2.0
2 gems installed
Exiting RubyGems with exit_code 0
[~]
$

Thanks!

I ran the info program from the manual. Here's the results:

shoes-info-3.3.8_r3371-angharad.txt

I don't see a GEM_HOME env var, and the "ext/gem" dirs seems to contain only Shoes-related stuff.

ccoupe pushed a commit that referenced this issue May 28, 2019
  the macosx-minver of 10.10. Not perfect but better.
@ccoupe
Copy link

ccoupe commented May 28, 2019

I see a couple of things to with your environment. (1) zsh - may be important. maybe not.
(2) I do have a a GEM_HOME=/Users/ccoupe/.shoes/+gem and you do not. That's important. It gets changed in lib/shoes/cache.rb which runs at startup of Shoes. ./cshoes -g env should give us a better idea of where Shoes is going to look for gems. The 'pristine' warning arises if the timestamp on the gem.build_complete file is wrong or the file doesn't exist. (configuration error, somewhere) the Psych::Syck::PrivateType reminds me of an old ruby with Syck instead of C yaml.

You do not have rvm so it's quite possible cache.rb is not rewriting it or creating it. Gem code does use that env var. You might try setting it before running Shoes. export GEM_HOME=/Users/janke/.shoes/_gem but that's for bash.

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