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

Can't package the app: NameError: uninitialized constant Bundler #1148

Closed
Le6ow5k1 opened this issue Jul 6, 2015 · 20 comments
Closed

Can't package the app: NameError: uninitialized constant Bundler #1148

Le6ow5k1 opened this issue Jul 6, 2015 · 20 comments

Comments

@Le6ow5k1
Copy link

Le6ow5k1 commented Jul 6, 2015

When I try to package an app:

shoes -p swt:app app.rb

I get the following error:

 Packaging swt:app...
 NameError: uninitialized constant Bundler
      const_missing at org/jruby/RubyModule.java:2726

full stack trace

I'm running it on Ubuntu 14.04 and using rvm with jruby-1.7.19.

It seems like the problem is not on shoes side, but...

@cfurrow
Copy link

cfurrow commented Jul 6, 2015

Can confirm this is happening on OSX 10.10.3, java 1.8.0_45, jruby 1.7.19, shoes 4.0.0.pre4

$ rbenv local
jruby-1.7.19
$ gem list

*** LOCAL GEMS ***

after_do (0.3.1)
axiom-types (0.1.1)
bundler (1.10.5)
coercible (1.0.0)
descendants_tracker (0.0.4)
equalizer (0.0.9)
ffi (1.9.3 java)
furoshiki (0.3.1)
ice_nine (0.11.1)
jar-dependencies (0.1.2)
jruby-jars (1.7.20.1)
jruby-launcher (1.1.1 java)
jruby-openssl (0.9.5 java)
jruby-rack (1.1.19)
json (1.8.0 java)
krypt (0.0.2)
krypt-core (0.0.2 universal-java)
krypt-provider-jdk (0.0.2)
maven-tools (1.0.7)
nokogiri (1.6.4.1 java)
plist (3.1.0)
rake (10.1.0)
rdoc (4.1.2)
ruby-maven (3.1.1.0.8)
ruby-maven-libs (3.1.1)
rubyzip (1.1.7)
shoes (4.0.0.pre4)
shoes-core (4.0.0.pre4)
shoes-highlighter (1.0.1)
shoes-manual (4.0.0)
shoes-package (4.0.0.pre4)
shoes-swt (4.0.0.pre4)
swt (4.4)
thread_safe (0.3.4 java)
virtus (1.0.4)
warbler (1.4.8)

Additional stack trace:

shoes -p swt:app app.rb
Packaging swt:app...
NameError: uninitialized constant Bundler
          const_missing at org/jruby/RubyModule.java:2726
                to_spec at /Users/carl/.rbenv/versions/jruby-1.7.19/lib/ruby/gems/shared/gems/warbler-1.4.8/lib/warbler/bundler_helper.rb:12
  find_single_gem_files at /Users/carl/.rbenv/versions/jruby-1.7.19/lib/ruby/gems/shared/gems/warbler-1.4.8/lib/warbler/gems.rb:58
                  specs at /Users/carl/.rbenv/versions/jruby-1.7.19/lib/ruby/gems/shared/gems/warbler-1.4.8/lib/warbler/gems.rb:46
                   each at org/jruby/RubyHash.java:1341
                    map at org/jruby/RubyEnumerable.java:763
                  specs at /Users/carl/.rbenv/versions/jruby-1.7.19/lib/ruby/gems/shared/gems/warbler-1.4.8/lib/warbler/gems.rb:46
        find_gems_files at /Users/carl/.rbenv/versions/jruby-1.7.19/lib/ruby/gems/shared/gems/warbler-1.4.8/lib/warbler/jar.rb:197
                  apply at /Users/carl/.rbenv/versions/jruby-1.7.19/lib/ruby/gems/shared/gems/warbler-1.4.8/lib/warbler/jar.rb:144
                package at /Users/carl/.rbenv/versions/jruby-1.7.19/lib/ruby/gems/shared/gems/furoshiki-0.3.1/lib/furoshiki/jar.rb:20
                  chdir at org/jruby/RubyDir.java:339
                package at /Users/carl/.rbenv/versions/jruby-1.7.19/lib/ruby/gems/shared/gems/furoshiki-0.3.1/lib/furoshiki/jar.rb:18
      ensure_jar_exists at /Users/carl/.rbenv/versions/jruby-1.7.19/lib/ruby/gems/shared/gems/furoshiki-0.3.1/lib/furoshiki/jar_app.rb:150
                package at /Users/carl/.rbenv/versions/jruby-1.7.19/lib/ruby/gems/shared/gems/furoshiki-0.3.1/lib/furoshiki/jar_app.rb:56
                    run at /Users/carl/.rbenv/versions/jruby-1.7.19/lib/ruby/gems/shared/gems/shoes-swt-4.0.0.pre4/lib/shoes/swt/packager.rb:29
                   each at org/jruby/RubyArray.java:1613
                    run at /Users/carl/.rbenv/versions/jruby-1.7.19/lib/ruby/gems/shared/gems/shoes-swt-4.0.0.pre4/lib/shoes/swt/packager.rb:25
                    run at /Users/carl/.rbenv/versions/jruby-1.7.19/lib/ruby/gems/shared/gems/shoes-core-4.0.0.pre4/lib/shoes/packager.rb:24
                    run at /Users/carl/.rbenv/versions/jruby-1.7.19/lib/ruby/gems/shared/gems/shoes-core-4.0.0.pre4/lib/shoes/ui/cli.rb:70
                 (root) at /Users/carl/.rbenv/versions/jruby-1.7.19/lib/ruby/gems/shared/gems/shoes-swt-4.0.0.pre4/bin/shoes-swt:11
                   load at org/jruby/RubyKernel.java:1087
                 (root) at /Users/carl/.rbenv/versions/jruby-1.7.19/bin/shoes-swt:23

@cfurrow
Copy link

cfurrow commented Jul 6, 2015

Got a little further by defining a Gemfile and bundling:

Gemfile:

source "https://rubygems.org"

gem 'shoes', '4.0.0.pre4'
gem 'shoes-swt'
gem 'warbler'
$ bundle
...snip..
$ bundle exec shoes -p swt:app app.rb
Packaging swt:app...
rm -f pkg/tmp/shopemailcsv.jar
Creating pkg/tmp/shopemailcsv.jar

The resulting pkg/*.app file did not end up working, nor did the pkg/*.jar, but it's progress, I suppose.

The .app fired this to the OSX console logs (app name is 'shopemailcsv'):
image

@PragTob
Copy link
Member

PragTob commented Jul 6, 2015

Hi there!

Thank you for your bug report and stack traces! Packaging is still a baby though, that needs to be treated gently :)

@Le6ow5k1 if you're on Linux you can't/shouldn't build app as .app is the Mac OSX format. We don't have a dedicated linux format yet - try packaging swt:jar in the meantime and run it through java -jar filename.jar

@cfurrow what did the .jar say when you ran it?

Thanks everyone!
Tobi

@cfurrow
Copy link

cfurrow commented Jul 6, 2015

@PragTob I pulled down the latest master branch, and ran rake install:all as well as installed jruby-1.7.20. Below I've got the output of running the jar.

$ shoes -p swt:jar app.rb
Packaging swt:jar...
rm -f pkg/the_app.jar
Creating pkg/the_app.jar

$ java -jar pkg/the_app.jar
Ignoring shoes-core-4.0.0.pre4 because its extensions are not built.  Try: gem pristine shoes-core --version 4.0.0.pre4
LoadError: no such file to load -- shoes
  require at org/jruby/RubyKernel.java:1072
  require at /var/folders/3h/2pmby1h526x90_n3vd1t7yjr0000gp/T/jruby1559663854543218074extract/jruby-stdlib-1.7.20.1.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:54
   (root) at file:/Users/carl/workspace/the_app/pkg/the_app.jar!/META-INF/init.rb:8
  require at org/jruby/RubyKernel.java:1072
   (root) at /var/folders/3h/2pmby1h526x90_n3vd1t7yjr0000gp/T/jruby1559663854543218074extract/jruby-stdlib-1.7.20.1.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:1
  require at /var/folders/3h/2pmby1h526x90_n3vd1t7yjr0000gp/T/jruby1559663854543218074extract/jruby-stdlib-1.7.20.1.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:54
ERROR: org.jruby.embed.EvalFailedException: (LoadError) no such file to load -- shoes

@PragTob
Copy link
Member

PragTob commented Jul 6, 2015

Thanks!

Ignoring shoes-core-4.0.0.pre4 because its extensions are not built. Try: gem pristine shoes-core --version 4.0.0.pre4 seems worrysome to me. shoes-core is also where there file loaded by require 'shoes' is defined.

I don't have time today (bed time!) or tomorrow... I'll see if I can give this another run through on my system Wednesday or so to see if I'm able to reproduce this issue.

It could be helpful if you have a minimal app file that you try to package. Otherwise I'll just try to package our sample app :)

Thanks!
Tobi

@cfurrow
Copy link

cfurrow commented Jul 6, 2015

Yeah, I'll play around some more with the sample apps, and maybe create my own simple app for testing, with more reproducible steps. I appreciate the help.

@chand1012
Copy link

I am also having the same Bundler Error on Windows 7 64bit when trying to package a jar file. As I am using the newest version of JRuby (9.0.0.0), I am going to try again using an older version of JRuby. I am using Java1.8.0_51 and shoes4.0.0pre4.

@PragTob
Copy link
Member

PragTob commented Aug 1, 2015

Sorry to say but it works for me on master...

tobi@airship ~/github/shoes4 $ ruby -v
jruby 9.0.0.0 (2.2.2) 2015-07-21 e10ec96 OpenJDK 64-Bit Server VM 24.79-b02 on 1.7.0_79-b14 +jit [linux-amd64]
tobi@airship ~/github/shoes4 $ bin/shoes -p swt:app samples/packaging/package_me.rb 
Packaging swt:app...
Downloading https://s3.amazonaws.com/net.wasnotrice.shoes/wrappers/shoes-app-template-0.0.2.zip to /home/tobi/.furoshiki/cache/shoes-app-template-0.0.2.zip
rm -f pkg/tmp/package_me.jar
Creating pkg/tmp/package_me.jar
tobi@airship ~/github/shoes4 $ java -jar samples/packaging/pkg/package_me.jar 
Ignoring executable-hooks-1.3.2 because its extensions are not built.  Try: gem pristine executable-hooks --version 1.3.2
Ignoring gem-wrappers-1.2.7 because its extensions are not built.  Try: gem pristine gem-wrappers --version 1.2.7
Ignoring jruby-launcher-1.1.1-java because its extensions are not built.  Try: gem pristine jruby-launcher --version 1.1.1

I'm on Linux Mint 17.2 (based on Ubuntu 14.04) and it just works.

@cfurrow still a problem for you?

@chand1012 could you supply a log?

Sorry for the long hold up :) Busy organizing JRubyConf.EU :)

@cfurrow
Copy link

cfurrow commented Aug 3, 2015

Hey @PragTob, yeah, it still seems like it's an issue for me on my own app, but not for the package_me.rb example.

  • I installed jruby-9.0.0.0.rc1 (couldn't find jruby-9.0.0.0 in ruby-build for some reason)
  • Grabbed latest from master, SHA 68bd6a8
  • Ran rake install:all
  • Created a new shoes app (and set .ruby-version to jruby-9.0.0.0.rc1)

It did not work without a Gemfile, so I copied the Gemfile from the shoes4 root dir, updated the paths to point to my local shoes4 repo that was up to date w/ master, and got my example app working.

I'll look into getting my other super-simple app working, but without the Gemfile there were bundler issues. Thanks for checking back in, and good luck organizing JRubyConf.EU. Exciting!

shoes -p swt:app app.rb                                                              
Packaging swt:app...
NameError: uninitialized constant Bundler
const_missing at org/jruby/RubyModule.java:3144
  to_spec at /Users/carl/.rbenv/versions/jruby-9.0.0.0.rc1/lib/ruby/gems/shared/gems/warbler-1.4.9/lib/warbler/bundler_helper.rb:12`

@PragTob
Copy link
Member

PragTob commented Aug 4, 2015

Hey @cfurrow !

Thanks for checking back! :) JRubyConf.EU already happened - it was great, thanks :)

Right now all I can say sadly is that packaging is still a baby... I've never done bundlign with a packaged app that is on the road map for some later point in time - but packaging quickly becomes the last big thing that we should tackle.

Sorry for the inconveniences everyone!

Tobi

@Malwine
Copy link

Malwine commented Sep 15, 2015

Dear people,
I had the same error output on Mac.
I did gem install bundler && bundle install again (! - why did it get uninstalled?) and then I could start the samples. I am not sure if that helpes to find the cause of the problem.
🐝

@lmrodriguezr
Copy link
Contributor

Hello everyone!
I'm having a very similar issue on Mac 10.10.5 with jruby 9.0.3.0 and a fresh pair of shoes (SHA 7fc6c6c). After some monkey patching, my app works wonderfully:

$ shoes-swt enveomics.rb # I get the same result with just `shoes enveomics.rb`
Wearing shoes.
2015-12-02 14:47:36.691 java[48990:6260381] *** WARNING: Method userSpaceScaleFactor in class NSWindow is deprecated on 10.7 and later. It should not be used in new applications. Use convertRectToBacking: instead. 

But when I try to package it:

$ shoes-swt -p swt:jar enveomics.rb # I get the same result with just `shoes -p swt:jar enveomics.rb`
Packaging swt:jar...
NameError: uninitialized constant Bundler
          const_missing at org/jruby/RubyModule.java:3181
                to_spec at /usr/local/Cellar/jruby/9.0.3.0/libexec/lib/ruby/gems/shared/gems/warbler-1.4.9/lib/warbler/bundler_helper.rb:12
  find_single_gem_files at /usr/local/Cellar/jruby/9.0.3.0/libexec/lib/ruby/gems/shared/gems/warbler-1.4.9/lib/warbler/gems.rb:58
         block in specs at /usr/local/Cellar/jruby/9.0.3.0/libexec/lib/ruby/gems/shared/gems/warbler-1.4.9/lib/warbler/gems.rb:46
                   each at org/jruby/RubyHash.java:1343
                    map at org/jruby/RubyEnumerable.java:800
                  specs at /usr/local/Cellar/jruby/9.0.3.0/libexec/lib/ruby/gems/shared/gems/warbler-1.4.9/lib/warbler/gems.rb:46
        find_gems_files at /usr/local/Cellar/jruby/9.0.3.0/libexec/lib/ruby/gems/shared/gems/warbler-1.4.9/lib/warbler/jar.rb:197
                  apply at /usr/local/Cellar/jruby/9.0.3.0/libexec/lib/ruby/gems/shared/gems/warbler-1.4.9/lib/warbler/jar.rb:144
       block in package at /usr/local/Cellar/jruby/9.0.3.0/libexec/lib/ruby/gems/shared/gems/furoshiki-0.3.1/lib/furoshiki/jar.rb:20
                  chdir at org/jruby/RubyDir.java:326
                package at /usr/local/Cellar/jruby/9.0.3.0/libexec/lib/ruby/gems/shared/gems/furoshiki-0.3.1/lib/furoshiki/jar.rb:18
           block in run at /usr/local/Cellar/jruby/9.0.3.0/libexec/lib/ruby/gems/shared/gems/shoes-swt-4.0.0.pre4/lib/shoes/swt/packager.rb:29
                   each at org/jruby/RubyArray.java:1560
                    run at /usr/local/Cellar/jruby/9.0.3.0/libexec/lib/ruby/gems/shared/gems/shoes-swt-4.0.0.pre4/lib/shoes/swt/packager.rb:25
                    run at /usr/local/Cellar/jruby/9.0.3.0/libexec/lib/ruby/gems/shared/gems/shoes-core-4.0.0.pre4/lib/shoes/packager.rb:24
                    run at /usr/local/Cellar/jruby/9.0.3.0/libexec/lib/ruby/gems/shared/gems/shoes-core-4.0.0.pre4/lib/shoes/ui/cli.rb:70
                  <top> at /usr/local/Cellar/jruby/9.0.3.0/libexec/lib/ruby/gems/shared/gems/shoes-swt-4.0.0.pre4/bin/shoes-swt:11
                   load at org/jruby/RubyKernel.java:957
                  <top> at /usr/local/Cellar/jruby/9.0.3.0/libexec/bin/shoes-swt:23

Since the error is a the missing Bundler, I thought maybe preloading the library would help, and it actually DID build the jar:

$ ruby -r bundler $(which shoes-swt) -p swt:jar enveomics.rb 
Packaging swt:jar...
rm -f pkg/enveomics.jar
Creating pkg/enveomics.jar

But alas, when I try to open it I get @cfurrow's error message:

$ java -jar pkg/enveomics.jar 
Ignoring shoes-core-4.0.0.pre4 because its extensions are not built.  Try: gem pristine shoes-core --version 4.0.0.pre4
LoadError: no such file to load -- shoes
  require at org/jruby/RubyKernel.java:1040
  require at /var/folders/jt/_hhggq8d5sv7wssfh7bgmqlm0000gp/T/jruby3443158316861674340extract/jruby-stdlib-1.7.23.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:54
   (root) at file:/Users/lmr3/enveomics/GUI/pkg/enveomics.jar!/META-INF/init.rb:8
  require at org/jruby/RubyKernel.java:1040
   (root) at /var/folders/jt/_hhggq8d5sv7wssfh7bgmqlm0000gp/T/jruby3443158316861674340extract/jruby-stdlib-1.7.23.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:1
  require at /var/folders/jt/_hhggq8d5sv7wssfh7bgmqlm0000gp/T/jruby3443158316861674340extract/jruby-stdlib-1.7.23.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:54
ERROR: org.jruby.embed.EvalFailedException: (LoadError) no such file to load -- shoes

I don't think I'm doing anything particularly wacky in my app, but here's the code just in case.

-- Miguel.

@PragTob
Copy link
Member

PragTob commented Dec 2, 2015

Thank you for the detailed bug report @lmrodriguezr - especially for providing it with code :)

What strikes me as a bit odd immedeatly is that it is rambling on about stdlib-1.7.23 but you have 9.0.3.0

packaging still is but a baby... I guess next step for us here would be to clone the repo and try to run and package up the app ourselves, might take us a while though (personally super busy the next 3 days)

Feel super free to ping us about it if we don't seem to have taken a look at it in a timely manner and thanks very much for your report! :)

Tobi

@lmrodriguezr
Copy link
Contributor

;tldr: If you use bin/shoes-swt from within the shoes4 directory, it works :bowtie:! But... jars are no friends of images 😒.

I tried again from the shoes dir, as in @PragTob's test, and I have no problems packaging:

$ cd ~/Software/shoes4
$ bin/shoes-swt -p swt:jar ~/enveomics/GUI/enveomics.rb 
Packaging swt:jar...
rm -f pkg/enveomics.jar
Creating pkg/enveomics.jar

But I get a very different error (perhaps this should be a different thread?). First, it fails to open in the foreground:

$ java -jar ~/enveomics/GUI/pkg/enveomics.jar 
***WARNING: Display must be created on main thread due to Cocoa restrictions.
Ooops, we couldn't start properly. We'll try again.

To avoid this restarting behavior, try one of the following:
  * Use the shoes executable to start your app
  * Add JRUBY_OPTS='-J-XstartOnFirstThread' to your environment before starting.
/bin/sh: -c: line 0: syntax error near unexpected token `newline'
/bin/sh: -c: line 0: `JRUBY_OPTS=-J-XstartOnFirstThread <script>'

But when I pass the option explicitly, it doesn't find a file within the jar (full trace here):

$ java -jar -XstartOnFirstThread ~/enveomics/GUI/pkg/enveomics.jar 
Wearing shoes.
Exception: i/o error (java.io.FileNotFoundException: /Users/lmr3/enveomics/GUI/pkg/enveomics.jar!/shoes-app/img/noun_208357_cc.png (No such file or directory))

java.lang.reflect.Constructor.newInstance(java/lang/reflect/Constructor.java:422)
RUBY.create_image(/Users/lmr3/enveomics/GUI/pkg/enveomics.jar!/gems/shoes-swt-4.0.0.pre4/lib/shoes/swt/image.rb:53)
[...]

The very weird thing is... the file it complains about is actually there (I opened the jar with vim):

[...]
732 shoes-app/enveomics.rb
733 shoes-app/img/
734 shoes-app/img/noun_208357_cc.png
735 shoes-app/img/noun_229118_cc.png
736 shoes-app/lib/
737 shoes-app/lib/enve-collection.rb
[...]

The error traces back to the line 171 in my code, which is inside a stack inside the app:

[...]
 23    $img_path   = File.expand_path("../img", File.dirname(__FILE__))
[...]
171                image File.expand_path("noun_208357_cc.png",$img_path),
172                   width: 50, height: 50, margin: 2
[...]

And when I remove the images, the whole thing works! Is there a way to put my lovely images back?
And yes, I get a similar error with samples/simple-image-fill.rb (trace here) 😔

Thanks!
-- Miguel

@PragTob
Copy link
Member

PragTob commented Dec 2, 2015

hey @lmrodriguezr that should indeed go to another thread :) There might actually already be one there for that, and the problem is referencing assets from within the package. I think it gets confused by being inside a jar (i.e. value of __FILE__ is of) and even if it weren't you probably couldn't access it because it is in the jar. We need to figure something out there. You could try just a relative path but I doubt that it'll work.

Also thanks for the observation that packaging works only with bin/shoes-swt we mgiht wanna have a look at that. Might be that your executable is old and we fixed it on master, or we might have another problem here. I'll open a ticket.

@lmrodriguezr
Copy link
Contributor

@PragTob yes, I found a couple of threads on it, sorry about that.

Might be that your executable is old and we fixed it on master

No, I'm sure I'm calling the shoes binary that gets installed from the gem, that I just built from the same fresh shoes4 folder. I think it might be something in the gemification, but at least this should provide a workaround for the original problem in this thread.

@jasonrclark
Copy link
Member

There's a lot of separate things going on here, but I've posted #1189 which for me takes care of the initial problem of not finding the Bundler constants when packaging.

I'm keen to get pre5 out, so the rest of this will take a bit longer to work through. I'm definitely seeing some weirdness with it picking up the wrong stdlib version when I'm on 9.0.4.0 😭

@PragTob
Copy link
Member

PragTob commented Dec 14, 2015

FYI this was reverted in #1208 due to reasons described there, we'll look for another solution to fix this up. Sorry for the inconvenience everyone :(

@lmrodriguezr
Copy link
Contributor

For the time #1189 was alive, I noticed it wasn't solving the Bundler constants problem either (but I didn't test carefully). I did notice it had significantly increased the size of the .jars, though.

@jasonrclark
Copy link
Member

The primary Bundler issues here is fixed with #1325 which should be out in the next pre release (pre8). If there are other things hanging on from here, we can re-raise them as separate issues as I give packaging more attention now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants