Closed Swatto closed 11 years ago
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!
@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.
@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 ?
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
@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 :)
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.
@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 :)
@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__
?).
@Spooner Do you think you can fix that or you don't know why it fails ?
@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. :)
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.
@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!
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).
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.
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!
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...
Thanks for you answer. I do respectively everything :
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 ?
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.
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.
Had the same issue. Try moving the app out of the dmg onto your desktop or to Applications.
@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.
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).
And how could it be done ? The arborescence of the disc is different on Mac and Windows.
save_dir = File.expand_path("~/.my_application")
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.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 chdir
s to application
, seems to be generated from https://github.com/Spooner/releasy/blob/master/lib/releasy/builders/osx_app.rb#L188
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.
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.
I closed this because it should have been posted in the issue actually dealing with main.rb (https://github.com/Spooner/releasy/issues/44)
After failling to launch complex game width releasy, I decide to test width the simplest code as possible :
I write the Rakefile :
I run the build and everything seems to work :
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.