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 lunch the build app on OS X #42

Closed
Swatto opened this issue Nov 7, 2012 · 28 comments
Closed

Can't lunch the build app on OS X #42

Swatto opened this issue Nov 7, 2012 · 28 comments
Assignees
Labels

Comments

@Swatto
Copy link

Swatto commented Nov 7, 2012

After failling to launch complex game width releasy, I decide to test width the simplest code as possible :

require 'rubygems'
require 'chingu'
include Gosu
include Chingu

class Game < Chingu::Window

  def initialize
    super(400,600)
  end

end

Game.new.show

I write the Rakefile :

require 'rubygems'
require 'bundler/setup'
require 'releasy'

Releasy::Project.new do
  name "testReleasy"
  version "1.0.0"
  verbose

  executable "main.rb"
  files [
    "main.rb",
    "media/*.*"
  ]
  add_link "http://www.example.com", "My website"
  exclude_encoding

  # Create a variety of releases, for all platforms.
  add_build :osx_app do
    url "com.example.testing"
    wrapper "wrappers/gosu-mac-wrapper-0.7.44.tar.gz"
    # icon "media/icon.icns"
    add_package :dmg
  end
end

I run the build and everything seems to work :

  • No errors
  • All the files are in the app

But when I lunch the app, it closes instantly the game (no message and no error visible).
I try with ruby 1.9.2 and 1.9.1 : no difference.

For information, I'm on Mac OS 10.8.2.

@ghost ghost assigned bil-bas Nov 7, 2012
@bil-bas
Copy link
Collaborator

bil-bas commented Nov 7, 2012

The .app wrapper actually contains Ruby 1.9.2 so that is what it will run your game with. It shouldn't matter what version is used to build it though (It has been tested with 1.8.7, 1.9.2 & 1.9.3, though I recommend 1.9.3).

The usual problem with an application not starting (.exe/.app) is that assets are being loaded based on an assumption of where the working directory is (you should always use file-relative paths). Obviously not the problem with your minimal example, of course!

I don't have access to OSX myself, so I will see if I can get someone to sanity check this for you - sorry!

@jlnr
Copy link
Member

jlnr commented Nov 7, 2012

@Swatto
OS X logs all the error during app launch in the console. Launch /Applications/Utilities/Console.app or enter Console into Spotlight to find it. Then clear it, and double-click your game again. You should see an error appear.

@Swatto
Copy link
Author

Swatto commented Nov 7, 2012

@jlnr Thanks for that ! I didn't know the possibility to see errors here.

Here's the errors that OS X have :

Dock: no information back from LS about running process
com.apple.launchd.peruser.501: ([0x0-0x2ba2ba].com.xXxXxXx.twist[23160]) Exited with code: 1

Any ideas ?

@bil-bas
Copy link
Collaborator

bil-bas commented Nov 7, 2012

The error you are looking for should be referring to "com.example.testing" not "com.apple.launchd.peruser" since that is the main reason for setting the #url in Releasy, I think. waits for jlnr to provide wisdom

@jlnr
Copy link
Member

jlnr commented Nov 7, 2012

@Swatto, is it possible for you to create a ZIP archive of the app and share it with me for testing?

@spooner, launchd is what is trying to open the .app :)

@Swatto
Copy link
Author

Swatto commented Nov 7, 2012

I create a zip with all the project. It contains the source code, the wrapper and the bugging app.

@jlnr, you can download the project here.
Thanks to investigate on this.

@jlnr
Copy link
Member

jlnr commented Nov 10, 2012

@Swatto: I am not sure why Console is not showing anything useful, it used to do so... @spooner Is Releasy redirecting $stderr anywhere?

So what I did is to run the game inside the pkg folder by hand from the Terminal:

Air:my_application_1_0_0_OSX jlnr$ My\ Application.app/Contents/MacOS/My\ Application 
[snip a lot of noise here]
Application.app/Contents/Resources/main.rb:12:in `chdir': No such file or directory - application (Errno::ENOENT)

And sure enough, main.rb does a Dir.chdir 'application', which does not exist. I am not sure if this is an issue with Releasy or with the Rakefile above. But that should help you guys figure it out :)

@bil-bas
Copy link
Collaborator

bil-bas commented Nov 10, 2012

@jlnr If Releasy is in verbose mode, then it should not suppress any messages at all.

I did see that line last time I looked at Releasy and thought "that shouldn't work", but since no-one had complained, I assumed it did ;) It should be an absolute, not relative path, since I don't know what dir the application has been run in - I can only assume that previous tests did work but that default directory has changed since then. I hope I didn't add that in a fit of madness after the last OSX test :$

Presumably it worked when you commented out that line (or changed it to the correct path relative to __FILE__?).

@Swatto
Copy link
Author

Swatto commented Nov 10, 2012

@spooner Do you think you can fix that or you don't know why it fails ?

@jlnr
Copy link
Member

jlnr commented Nov 11, 2012

@spooner I think it'd work just fine if you replaced load 'main.rb' by require_relative 'application/main' as the last line.

Also, strictly speaking, the file inside Resources (the main.rb supplied by Releasy) should be Main.rb because that's what Gosu is loading, and you can configure OS X to be case sensitive. Though I really don't know who does that, and why. :)

@bil-bas
Copy link
Collaborator

bil-bas commented Nov 11, 2012

Hmm, it should be created as Main.rb, but I suppose that wouldn't be an error when I test it on Windows if I did get that wrong :/ The "application/main" is just running the executable the user defined.

@bil-bas
Copy link
Collaborator

bil-bas commented Nov 11, 2012

@Swatto I think jlnr worked it out last night. The workaround (without having to hack the generated files and until I fix Releasy :$) is to avoid having any files called "main.rb" in your game. Please confirm if this works and I'll make a proper bug report for this issue. Thanks!

@Swatto
Copy link
Author

Swatto commented Nov 12, 2012

I confirm : this solve my problem with this simple test. Name a file "main.rb" breaks on OS X.

Now I need to debug my real game that don't launch too. I will post here the newest version if you can help me (this will be the gift for my godson's birthday).

@Swatto
Copy link
Author

Swatto commented Nov 12, 2012

I rename my "main.rb' but I can't launch it too.
If someone can't take a look at my game, it would be cool.

Sorry for the french comment but my godson want to learn programming so I explain the code of the game.

@bil-bas
Copy link
Collaborator

bil-bas commented Nov 12, 2012

Had a poke around:

Releasy isn't a run-time dependency, so you should do this in your gemfile:

group :development do
  gem "releasy"
end

This means it won't get included in the Releasy releases or pointlessly loaded when you start the game itself, but you will need to change your rakefile:

require 'bundler'
Bundler.require :development # Only require Releasy, since we don't need to load Gosu/Chingu at this point.

Don't use MP3 sounds, since they aren't supported by Gosu on all platforms (e.g. I couldn't get them to work on Windows). Use Ogg Vorbis (.ogg) instead - you can use Audacity to convert them easily!

@bil-bas
Copy link
Collaborator

bil-bas commented Nov 12, 2012

Oh, otherwise it seemed OK. You correctly set the Chingu asset load paths and use require_relative everywhere, so you aren't making any assumptions about the current working directory, which is good. Please re-check the console log to see if any errors are going there, now we've resolved the main.rb issue...

@Swatto
Copy link
Author

Swatto commented Nov 12, 2012

Thanks for you answer. I do respectively everything :

  • Ogg files
  • the development group in the Gemfile
  • the modification in the Rakefile

This don't fix the problem. Here's the log that the console gives me :

com.apple.launchd.peruser.501[273] ([0x0-0x67e67e].com.coool.twist[12094]): Exited with code: 1

If you try to build it on your computer, does it failed or not ? Could we try to fix it on my repo to avoid to spam here and take the conclusion of the modification to fix Releasy ?

@bil-bas
Copy link
Collaborator

bil-bas commented Nov 12, 2012

Well, it runs on Windows, now that the ogg files replaced the mp3s, which helps me ;)

I tried building with Ocra and it didn't seem to like Bundler.require (although I like that a lot). Not sure if the OSX .app can cope with it, so maybe try it more manually:

require 'bundler/setup' unless defined?(OSX_EXECUTABLE) or ENV['OCRA_EXECUTABLE']
require "gosu"
require "chingu"

Note that there is absolutely no reason to use Bundler inside an exe/app, since there can't be more than one version of the gems. All using it does is extend the duration of the startup phase. This is something I need to document further...eventually.

@Swatto
Copy link
Author

Swatto commented Nov 12, 2012

This simple line

require 'bundler/setup' unless defined?(OSX_EXECUTABLE) or ENV['OCRA_EXECUTABLE']

Fix everything. Thank you for your patience.

I think you should edit your readme file with the Main.rb issue and this line too.

@ariejan
Copy link

ariejan commented Dec 12, 2012

Had the same issue. Try moving the app out of the dmg onto your desktop or to Applications.

@Swatto
Copy link
Author

Swatto commented Dec 12, 2012

@ariejan it's looks like logic to me if the program want to write some code in the app (like high score) in the dmg, it will crash.

@bil-bas
Copy link
Collaborator

bil-bas commented Dec 12, 2012

You should really be writing high scores (or settings files) into somewhere like ~/.my_application/scores.yml rather than into a file next to the executable. This also avoids the problem of people on Windows putting the executable into Program Files (which people do, although the running program won't have write rights).

@Swatto
Copy link
Author

Swatto commented Dec 12, 2012

And how could it be done ? The arborescence of the disc is different on Mac and Windows.

@bil-bas
Copy link
Collaborator

bil-bas commented Dec 12, 2012

save_dir = File.expand_path("~/.my_application")

#expand_path will resolve the ~ for you to the user's home directory. You could alternatively use ENV['APPDIR'], if set which I think is the more normal application directory on Windows, but I'm sure no-one would mind if you just stuck it in the user's home directory.

@daniero
Copy link

daniero commented Sep 28, 2013

When I finally got Rake to work (after struggling with version hell for an hour or two), the app wouldn't load at all. I checked the contents of the .app package and found that there was something wrong in pkg/testapp_1_0_OSX/testapp.app/Contents/Resources/Main.rb: When I change line 12 to the following, everything works:

Dir.chdir '../Resources/application'

The original line, which only chdirs to application, seems to be generated from https://github.com/Spooner/releasy/blob/master/lib/releasy/builders/osx_app.rb#L188

@bil-bas
Copy link
Collaborator

bil-bas commented Sep 28, 2013

Regarding Rake, you should just be able to use "bundle exec rake". I suspect, however, that I should be a lot more permissive about rake versions.

@bil-bas bil-bas closed this as completed Sep 28, 2013
@jlnr
Copy link
Member

jlnr commented Sep 28, 2013

Oops - edit: I'll also try to reproduce the Dir.chdir thing. This bug still somehow sounds familiar :) But I'll comment on the right ticket next time.

@bil-bas
Copy link
Collaborator

bil-bas commented Sep 28, 2013

I closed this because it should have been posted in the issue actually dealing with main.rb (#44)

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

No branches or pull requests

5 participants