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

Packaged App Working dir is / #1479

Open
janrenz opened this issue Sep 29, 2017 · 1 comment
Open

Packaged App Working dir is / #1479

janrenz opened this issue Sep 29, 2017 · 1 comment

Comments

@janrenz
Copy link

janrenz commented Sep 29, 2017

If i package an app (tested under Mac OS) and i try to load some files that are part of the jar this files. Some debugging later i found out that the working Dir of the app is '/'

Dir.getwd printed '/', and this is not within the jars sandbox or so:
Debugging alert:

alert(Dir.entries(Dir.getwd).flatten)

screen shot 2017-09-29 at 17 30 36

So how can i load files packaged in the jar with ruby.
@PragTob Mabybe you can help you old teacher :)

@jasonrclark
Copy link
Member

Hi @jprberlin! So it turns out that we can't guarantee a consistent working directory for packaged apps, especially between operating systems.

The recommendation for finding files that are within your package is to look for them relative to your source files:

# From some Ruby file in your project
file_to_read = File.read(File.join(__FILE__, "../other/file.rb"))

Images will automatically work relative to your application root by themselves when used with the Shoes image method, but other file types you'll need to handle yourself relatively. Does that make sense?

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