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

Wrong path location for relative config file #131

Open
hadmut opened this issue Jul 24, 2024 · 1 comment
Open

Wrong path location for relative config file #131

hadmut opened this issue Jul 24, 2024 · 1 comment

Comments

@hadmut
Copy link

hadmut commented Jul 24, 2024

Hi,
using sinatra 4.0.0 and sinatra-activerecord 2.0.27 I observed this problem:

As long as I don't configure the database in my application, but just have a config/database.yml in the root directory of my application (i.e. the CWD of the running process), things work.

But once I set something like

set :database_file, "config/database.yml"

things break with an error message

Errno::ENOENT: No such file or directory @ rb_sysopen - ${PATH_of_my_Gems_dir}/gems/sinatra-contrib-4.0.0/lib/sinatra/config/database.yml (Errno::ENOENT)
${PATH_of_my_Gems_dir}//gems/sinatra-activerecord-2.0.27/lib/sinatra/activerecord.rb:78:in read' ${PATH_of_my_Gems_dir}//gems/sinatra-activerecord-2.0.27/lib/sinatra/activerecord.rb:78:in database_file='

It then tries to read the database file from a wrong location, i.e. within the gems repository instead of the running application or the CWD where the process was run.

@cupnoodle
Copy link
Member

May I know what was the pwd (present work directory) when you run the rake command? The gem is using "Rake.application.original_dir" as the root directory to find the database file, which from my knowledge, it depends on the pwd when the rake command is invoked. (https://stackoverflow.com/a/260137)

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