Closed robinboening closed 10 years ago
Some for me. Using spring 0.0.8
from rubygems.org. And even tried to clone the github repo and installed the gem locally. Same issue.
I put the spring.rb
in GEM_ROOT/config/spring.rb
and in GEM_ROOT/spec/dummy/config/spring.rb
Neither works.
So what are we missing? Maybe @senny can clarify?
From the error it looks like your configuration file is not found and therefore the application_root
option is not specified. The code to load the config file is at: https://github.com/jonleighton/spring/blob/master/lib/spring/commands.rb#L241-L242
How are you executing spring? From what pwd
?
As a side note, the config file goes in:
<engine_root>/config/spring.rb
Yes, from the gem root. In my case:
/Users/tvd/code/ruby/gems/alchemy_cms
Yep, and this doesn't work.
Github mail parsing.... :(
@tvdeyen please also post the command you are executing...
spring rspec
But also just spring
will throw the message.
I puts
'ed the config = File.expand_path("./config/spring.rb")
from https://github.com/jonleighton/spring/blob/master/lib/spring/commands.rb#L241 and it does not was printed.
So I guess, the MissingApplication
error gets raised to soon. Before the config file is even evaluated.
@senny is it working for you? In an gem engine? Can you post an example of the usage?
thanks. I'm at work right now but I'll take a look when I have some spare time.
I am also at work right now ;) And I want to write some tests...
Have you an working example of your implementation?
My guess is it that while instantiating Spring.Application.new
the problem starts, because it's constructor parameter defaults to Spring.watcher
and that calls the Spring.application_root_path
method.
https://github.com/jonleighton/spring/blob/master/lib/spring/application.rb#L11
https://github.com/jonleighton/spring/blob/master/lib/spring/watcher.rb#L14
Maybe the config.rb
file gets evaluated to late. It has to be loaded before Spring::Server
starts.
I finally had time to take a look at this one. It also didn't work for me with the released spring 0.0.8 but it works if you use the current master version from GitHub.
@jonleighton is there a new release planned?
Unfortunately it doesn't work for me if I install the gem locally from cloned github master. Neither it works from bundler with local path option.
Maybe I miss something?
Thanks for looking into it.
@tvdeyen can you make a fresh empty engine and wire up spring and upload it to github?
Sorry, not at work.
But this is easy as 1,2,3:
$ rails new plugin spring_test --mountable --dummy-path=spec/dummy -T
$ spring rspec
@tvdeyen ping me when you uploaded an application. I tried to reproduce locally and it worked.
Please clone:
https://github.com/magiclabs/alchemy_cms
Then run:
$ bundle install
$ rake alchemy:spec:prepare
$ spring rspec
This application does not even have spring configured => https://github.com/magiclabs/alchemy_cms/tree/master/config
I need an isolated engine with spring configured that fails on your machine.
Yeah, you are right. Sorry about that. I am managing this via mobile phone while I am on vacancy.
This isolated engine is the one failing.
Couldn't you just put in a config/spring.rb that points to spec/dummy? That would be very much appreciated.
Many thanks for your patience. Next beer is on me :)
This isolated engine is the one failing.
There is no link...
Of course I can post an example config/spring.rb
but it seems that the contents of this file is not the problem:
config/spring.rb
Spring.application_root = './test/dummy'
My time is limited, I will continue looking into this, when someone submits an isolated (blank rails engine) with spring configured that is not working for them locally.
This isolated engine is the one failing.
There is no link...
https://github.com/magiclabs/alchemy_cms Of course I can post an example config/spring.rb but it seems that the contents of this file is not the problem:
config/spring.rb
Spring.application_root = './test/dummy' ./spec/dummy
@tvdeyen As stated before. I'm not going to configure the engine you posted. It has a huge load of dependencies. I'm looking for a blank rails engine with Spring configured that fails on your machine. Upload that and I'll take another look.
@senny you can use this one
$ git clone git@github.com:robinboening/spring_test.git && cd spring_test
$ spring rspec
This ends up with the error notice, while calling rspec
just works.
(Using manually installed spring gem from cloned github repository)
<3 @robinboening
@robinboening thanks for the engine. My verification against the local git used an older version, which is why it worked. Does #147 work for you?
$ spring rspec
You are using an old or stdlib version of json gem
Please upgrade to the recent version by adding this to your Gemfile:
gem 'json', '~> 1.7.7'
/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.7/lib/sqlite3/database.rb:91:in `initialize': ArgumentError: prepare called on a closed database: SELECT name (ActiveRecord::StatementInvalid)
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
AND name = "alchemy_attachments"
from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.7/lib/sqlite3/database.rb:91:in `new'
from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.7/lib/sqlite3/database.rb:91:in `prepare'
from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/sqlite_adapter.rb:246:in `block in exec_query'
from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/sqlite_adapter.rb:242:in `exec_query'
from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/sqlite_adapter.rb:335:in `tables'
from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/sqlite_adapter.rb:341:in `table_exists?'
from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/schema_cache.rb:30:in `table_exists?'
from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/model_schema.rb:223:in `table_exists?'
from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/acts-as-taggable-on-2.4.1/lib/acts_as_taggable_on/acts_as_taggable_on/cache.rb:5:in `included'
from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/acts-as-taggable-on-2.4.1/lib/acts_as_taggable_on/taggable.rb:98:in `include'
from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/acts-as-taggable-on-2.4.1/lib/acts_as_taggable_on/taggable.rb:98:in `taggable_on'
from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/acts-as-taggable-on-2.4.1/lib/acts_as_taggable_on/taggable.rb:39:in `acts_as_taggable_on'
from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/acts-as-taggable-on-2.4.1/lib/acts_as_taggable_on/taggable.rb:15:in `acts_as_taggable'
from /Users/tvd/code/ruby/gems/alchemy_cms/app/models/alchemy/attachment.rb:6:in `<class:Attachment>'
...
Running it only with rspec
it works fine.
So I guess there is an issue with gem environment while running with spring?
Same here.
Am 22.05.2013 um 21:49 schrieb Thomas von Deyen notifications@github.com:
147 works with the bare engine from @robinboening, but it fails with the alchemy engine with this error:
$ spring rspec You are using an old or stdlib version of json gem Please upgrade to the recent version by adding this to your Gemfile:
gem 'json', '~> 1.7.7'
/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.7/lib/sqlite3/database.rb:91:in
initialize': ArgumentError: prepare called on a closed database: SELECT name (ActiveRecord::StatementInvalid) FROM sqlite_master WHERE type = 'table' AND NOT name = 'sqlite_sequence' AND name = "alchemy_attachments" from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.7/lib/sqlite3/database.rb:91:in
new' from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.7/lib/sqlite3/database.rb:91:inprepare' from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/sqlite_adapter.rb:246:in
block in exec_query' from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_adapter.rb:280:inblock in log' from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/notifications/instrumenter.rb:20:in
instrument' from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_adapter.rb:275:inlog' from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/sqlite_adapter.rb:242:in
exec_query' from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/sqlite_adapter.rb:335:intables' from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/sqlite_adapter.rb:341:in
table_exists?' from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/schema_cache.rb:30:intable_exists?' from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/model_schema.rb:223:in
table_exists?' from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/acts-as-taggable-on-2.4.1/lib/acts_as_taggable_on/acts_as_taggable_on/cache.rb:5:inincluded' from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/acts-as-taggable-on-2.4.1/lib/acts_as_taggable_on/taggable.rb:98:in
include' from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/acts-as-taggable-on-2.4.1/lib/acts_as_taggable_on/taggable.rb:98:intaggable_on' from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/acts-as-taggable-on-2.4.1/lib/acts_as_taggable_on/taggable.rb:39:in
acts_as_taggable_on' from /usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/acts-as-taggable-on-2.4.1/lib/acts_as_taggable_on/taggable.rb:15:inacts_as_taggable' from /Users/tvd/code/ruby/gems/alchemy_cms/app/models/alchemy/attachment.rb:6:in
class:Attachment' ... Running it only with rspec it works fine.So I guess there is an issue with gem environment while running with spring?
— Reply to this email directly or view it on GitHub.
This failure feels unrelated, to this issue. From the stack-trace it looks like acts-as-taggable
is somehow involved. I would need to debug this. The fact that you no longer get the error reported in this ticket, means, that it in fact works for both projects.
Sorry, I don't think this can be closed, because as stated above, the error only raises with spring command, not if running alone with rspec command.
Maybe this is somehow Gemfile related? According to your commit you ignore the engines Gemfile.
Hopefully I find some time tonight to look into this and will give you feedback.
Thanks so far for your help.
@tvdeyen this issue is about "config/spring.rb not loaded if used within engine" with the referenced patch, this file is loaded so we are going to close it when the patch gets merged.
Please open a new issue for the exception related to acts-as-taggable
it's not related to this discussion.
You are right. I will open a new issue after this is merged, because I believe this was introduced by your patch.
@tvdeyen why do you think it's related to this patch?
So, I got it working, somehow.
This is what I did, to get this working:
spring
gemspring.rb
in ./config/
of my engine root dir (~/code/ruby/gems/alchemy_cms
)Spring.application_root = 'spec/dummy'
into ./config/spring.rb
Calling the spring
command I got the same error like before:
Spring was unable to find your config/application.rb file. Your project root was detected at /Users/tvd/code/ruby/gems/alchemy_cms, so spring looked for /Users/tvd/code/ruby/gems/alchemy_cms/config/application.rb but it doesn't exist. You can configure the root of your application by setting Spring.application_root in config/spring.rb.
spec/dummy/config/application.rb
into ./config/
./Gemfile
into ./spec/dummy/
./Gemfile.lock
into ./spec/dummy/
Now it works.
PS: I fixed the You are using an old or stdlib version of json gem
error with using gem 'multi_json', '1.7.2'
. Like mentioned in http://stackoverflow.com/q/16543693
Thanks @jonleighton this commit fixes all issues. Now it works :heart:
I installed the latest version of spring, but still got this same error,
/home/elbbub/.rvm/gems/ruby-2.0.0-p247/bundler/gems/spring-38214cfd773d/lib/spring/configuration.rb:26:in application_root_path': Spring was unable to find your config/application.rb file. Your project root was detected at /home/elbbub/D.works/projects/_plugins/blorgh4m_ori_test, so spring looked for /home/elbbub/D.works/projects/_plugins/blorgh4m_ori_test/config/application.rb but it doesn't exist. You can configure the root of your application by setting Spring.application_root in config/spring.rb. (Spring::MissingApplication) from /home/elbbub/.rvm/gems/ruby-2.0.0-p247/bundler/gems/spring-38214cfd773d/lib/spring/configuration.rb:20:in
verify_environment'
.
.
.
my ruby version is 2.0-p247, rails is 4
Yep, same for me using Spring 1.0.0, Rails 4 and Ruby 2.0.0-p247 ;(
@elbbub @tvdeyen can you guys provide an example plugin that shows how to reproduce the problem?
Sure. I made a vanilla rails 4 demo engine:
$ rails --version
4.0.2
$ rails plugin new spring_1_0_0_test
Got the same error:
Spring was unable to find your config/application.rb file.
$ gem list spring
*** LOCAL GEMS ***
spring (1.0.0)
spring-commands-rspec (1.0.1)
$ ruby --version
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin13.0.0]
$ gem --version
2.1.10
$ rspec spec/
..*.........................*.
Finished in 0.26027 seconds
30 examples, 0 failures, 2 pending
$ spring rspec
Spring was unable to find your config/application.rb file. Your project root was detected at /Users/tvd/code/ruby/gems/spring_1_0_0_test, so spring looked for /Users/tvd/code/ruby/gems/spring_1_0_0_test/config/application.rb but it doesn't exist. You can configure the root of your application by setting Spring.application_root in config/spring.rb.
See for yourself: http://github.com/tvdeyen/spring_1_0_0_test
@jonleighton could you please reopen this issue? Since spring is going to be merged into rails with 4.1 I think this really has to be fixed first ;)
@tvdeyen sure, I look forward to seeing your pull request
I did a little of investigation. Attribute application_root
in configuration.rb
file will be null, because configuration gets executed before commands.rb
where we look into ~/.spring.rb
or ./config/spring.rb
. So, if I just put loading of config file into configuration.rb
it will work, but that's probably not OK, because this gets executed every time you run spring command...
I'm totally new to this gem and I don't really know how exactly should everything work.
Running Rails 3.2.15, everything works fine when I follow these steps:
rails plugin new spring_test
cd spring_test
echo 'gem "spring", :group => :development' >> Gemfile
bundle install
mkdir config
echo "Spring.application_root = './test/dummy'" > config/spring.rb
bundle exec spring binstub --all
But that's because binstub is explicitly requiring "spring/commands"
before it gets called. It might fail with other commands. I'm going to try some others and see if I can make it break…
Correct me if I'm wrong:
In 16f5a24b776ac70e79835f9c5621d150ad5d0dc3 @jonleighton stopped application.rb from requiring "spring/commands", the file responsible for requiring the config files, because it would load in all the custom command gems whenever the client runs, and that's slow.
However, since then the config files have started being used to manually set the application_root_path
, which is necessary if you're running the spring client in an engine.
When the client runs it checks to see if the server is running, and boots it if necessary. The boot_server method requires "spring/server"
, which requires "spring/commands"
, so it's fine. The problem is the unless env.server_running?
, which is run before we require spring/commands
, and hence before we have application_root_path.
To check if the server is running, it has to check the pidfile, which is named after the application_id, which is a hex digest of the application_root_path.
So! What are the potential solutions? We need the client to be able to check the status of the server without loading custom command gems. We could:
1) Make the pidfile not dependent on the application_root_path 2) Have separate config files (or separate sections in the same file) for loading custom commands vs. configuring options
Thoughts?
Or we could autodetect when there's a dummy app and use that as the application root path...
Thanks @atroche. This should be fixed by the above commit.
Confirmed working \o/
Thanks @jonleighton :heart:
In contrast to #37 the
config/spring.rb
is not loaded within an engine.I followed the instructions from the readme and created the
config/spring.rb
.The engine´s dummy application is located in
spec/dummy
, so I configured the application_root like that:Unfortunately without success and I got the error notice:
Did I miss something? If so, it should be mentioned in the readme.