Closed bluerouse closed 10 years ago
It looks like this is caused by the fact that this gem includes its own Gemfile.lock
. Because of this, this forces any other dependent projects to also use the same versions.
In general, Gemfile.lock
should never be included in gems (but should be included when developing apps). See http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/:
When developing a gem ... Do not check your Gemfile.lock into version control, since it enforces precision that does not exist in the gem command, which is used to install gems in practice. Even if the precision could be enforced, you wouldn’t want it, since it would prevent people from using your library with versions of its dependencies that are different from the ones you used to develop the gem.
The Gemfile.lock
should definitely not be in the repo, so I merge #32
However, I'm not sure this is causing the issue at hand here. The only runtime depency, as defined in the gemspec, should be rails >= 3.1
.
@bluerouse can you still test with the current master if that should fix your issue after all?
The proper solution for middleman compatibility would probably be to depend on sprockets
(I think >= 2.0.0
) instead of rails
. I would gladly take PR for that if somebody can confirm that it fixes middleman compatibility.
Errormessage remains the same. Seems like there is a bigger issue than just the gemfile.lock was.
Just as I thought. Would you be able to create a new fork of the gem with the rails dependency replaced with sprockets (as described above) and let me know if that fixes things for you?
this is the relevant line: https://github.com/zweilove/css_splitter/blob/master/css_splitter.gemspec#L20
Thanks for your help! I did this change and now "bundle install" is successful. But the gem throws an error now:
engine.rb:2:in `module:CssSplitter': uninitialized constant Rails (NameError)
Ah, right. In that case we would need a different way to register the SprocketsEngine
(https://github.com/zweilove/css_splitter/blob/master/lib/css_splitter/engine.rb). Unfortunately I don't really know how to do that :( Maybe sombody that knows middleman well could help?
Tried the following:
What did I miss to try? I'm not that familiar with Ruby, the errors are quite hard to understand.
Probably middleman-developers got an idea? @tdreyno @bhollis
Thanks for your help!
Looks like the base css_splitter
lib file automatically sets up Rails support, which doesn't exist in Middleman:
require "css_splitter/engine"
require "css_splitter/sprockets_engine"
require "css_splitter/splitter"
module CssSplitter
end
I'd replace your require "css_splitter"
with a truncated version of their includes:
require "css_splitter/sprockets_engine"
require "css_splitter/splitter"
module CssSplitter
end
Simply omitting the Rails engine, but keeping the Sprockets support. I'll let this gem's authors comment on whether that will actually work.
This should already help by only loading the engine integration if Rails
is actually defined 62039bcb8b1eac963df02f058f7e7ca987358408
However, you will somehow need to register the gem's SprocketsEngine
as a bundle processor in Middleman, and I'm not sure how that would work (see: https://github.com/zweilove/css_splitter/blob/master/lib/css_splitter/engine.rb#L6)
Changing s.add_dependency "rails", ">= 3.1"
line to use add_development_dependency
instead in css_splitter.gemspec
might also help. In addition, because the Rails dependency would no longer be required, I would add a dependency on sprockets
instead.
Yes, now i could bundle my project with css_splitter and also start middleman! I didn't reached to register the precompile-thing. Probably middleman handles this already for me? I tried to register config.assets.precomile in my config.rb, but this didn't work.
But i even tried to open a page in project without this precompile-registering, then errormessage is like this: undefined method `split_stylesheet_link_tag' for #Middleman::Application:0x70215241268140
I think solution is very close, probably i made a small thing wrong?
Thanks for your support!
You will need to find the correct way of registering the bundle processor and including the split_stylesheet_link_tag
helper in Middleman, otherwise you might be able to bundle the gem, but it's functionality will not be registered in your app. I would love to help more, but I have no experience with Middleman.
@bluerouse We don't precompile on our side, but open a ticket in our repo and I'll help you re-implement (or copy/import) the split_stylesheet_link_tag
helpers into the Middleman environment.
As the dependecy issues are fixed, I'm closing this ticket. Thanks a lot for your help!
I just found your gem, which would do exactly what i'm currently searching for. I've got now some issues: we rely on middleman in the Version 3.1.6 and this makes some dependency-problems with your gem:
How can i solve this? Is there a way for me to use your gem without using older gems than now?
Thanks a lot for your help!