-
Notifications
You must be signed in to change notification settings - Fork 8
Support cross-platform development #4
Comments
👍 to getting this resolved. |
+1. I would like to see something like this for Mac's too. Fot example I have problems installing libv8 3.11.8.13 under 10.9, so I use 3.16, but on the other hand on server 3.16 doesn't work on server, so I can't change it in Gemfile.lock. |
Ignoring platform-specific Gemfile.lock Yes, this is not supposed to be how it works. But rubygems/bundler-features#4 references a long history of complaints and they are fixing this to make Gemfile.lock be more cross-platform. If we don't ignore it, we'll be checking in this file over and over again if we want to work on Windows, Mac, and Linux.
Suggestion: Maintain a dependency section for each platform in Gemfile.lock and warn/error if versions differ |
This one affected me again yesterday, when deploying cross platform I'm always forced to |
As a possible workaround, how does bundler detect the architecture? Obviously you don't want to run bundle install for a foreign architecture, but when using |
+1 for @MichaelSp's suggestion. Easy to understand and obvious. We are using compass and need to lock down the SCSS version, so need the .lock file. We do not use rake, so a rake fix is not helpful. |
This appears to have been a problem for a long time with no solution. As another sample of the problem I am running the pry gem on Mac, Linux and Windows. The Windows gem dependency includes win32console which causes the lock file difference. Whether the Gemfile.lock is made smarter by isolating dependencies by platform or just allow me to add a override Gemfile..lock for additional platform specific gems. Either would work for me. Since bundler creates this file, it should be able to diff the current version, know which platform it was created on, and make appropriate delta changes to the current platform. The output is a set of common gems and a set of platform specific gems. |
We ran into the same problem. I'd love to see something like "bundle package --architecture $ARCH" |
👍 Would be very very helpful |
This is very, very hard to fix in a reliable way. If you At a minimum, please run a CI server on the same platform as your production servers, and use the Gemfile.lock from a passing CI build when you deploy. |
👍 |
2 similar comments
👍 |
👍 |
@indirect That would mean that your CI server would have to be able to commit to your repository. And you would not know the end result beforehand either. The most common use case for this that I have seen is people using tl;dr: Even if no solution is perfect, any solution is better than none. |
Addendum: For some gems, the version string that ends up in Gemfile.lock includes the platform (nokogiri comes to mind), for some (e.g. libv8), it doesn’t. I haven’t looked into why this is happening or even if this is still happening, but gems like libv8 are completely unproblematic here since all the different architecture’s gems fulfill the version condition. So maybe if bundler just always stored arch-independent version strings in the Gemfile.lock…? |
@moeffju Darwin and Linux currently share gems only because the gem requires you to build C extensions at install-time. If there are different gems for different platforms, those gems can have completely different dependencies. For example, Nokogiri on windows depends on a gem that Nokogiri for Linux/Darwin does not depend on. Completely different dependencies means completely different lock file, and makes it a terrible idea to cache gems for a different platform, because you won't even know whether your production app can boot or not until after you've deployed it. |
@indirect Yes, but bundler can still pretend to run on a different platform and resolve those dependencies, can’t it (provided they are gem dependencies and not lib dependencies, but those are out of scope anyway)? |
The entire reason Bundler exists is to make sure that you run the same code in development as in production. You're asking for Bundler to "just" let you run completely different code in development and production... at that point, you can just as well delete your Gemfile.lock before bundling during production deploys, and this entire discussion is pointless. On Thu, Feb 26, 2015 at 2:55 PM, Matthias Bauer notifications@github.com
|
Why not add a declaration Node NPM's Shrinkwrap feature supports cross platform with no problem. |
In Bundler 1.8, It looks like this hasn't made its way into the docs yet, though. Help with that would be appreciated! |
@TimMoore According to the spec and a cursory local testing, that only includes any other ruby platforms, but not all cpu arches. I.e. it does not install |
@indirect I’m aware of what bundler’s intentions are, but what is the alternative? The current situation is that lots of people develop on a platform that is different from their deployment platform. Ruby as an interpreted language facilitates this, because your Ruby code usually runs no matter what the underlying platform is (with some caveats). Your scenario of “completely different code” running in dev and prod, how often does that really happen? libv8 on linux does the same as libv8 on darwin. It could theoretically generate PNGs of kittens instead, but – why would it? Maybe if you could give an example of a gem that works noticeably different on a different platform, that would be helpful for our understanding. There is a pain point here, and all the suggested workarounds come with their own problems:
Of all the alternatives, having bundler download and cache the gem for different platforms seems like the most obvious, simplest, and least brittle option. The only failure case here is if a) a gem does wildly different things on different platforms, which afaik is comparatively unlikely, and b) people deploy to a different platform for production without testing the app on that platform first, whether on a CI or through manual QA, which is not a great idea anyway. If people want to shoot themselves in the foot, they will do it no matter whether bundler supports them or not. Adding multi-arch support to bundler at least hands them an unloaded gun pointing away from their body. So my recommendation would be to add an option ( |
For example libv8 runs fine on 64-bit Linux and segfaults on 32-bit Linux. |
@ignisf Well, while I would agree that that is wildly different per platform, it’s not “doing” different things, it just has bugs on some platforms. Bundler caching different platform’s gems does not preclude people from proper testing and QA – e.g. we run CI builds on the same platform/arch that we deploy on, plus run staging environments. If you don’t do that, your deployment may break for a variety of reasons. |
My project has 200+ gems and we have developers on Windows, Mac, and Linux without issue. Gem not working on different platforms with MRI is the exception not the rule. |
I think there are quite a few ways to go. What I think we should not do is to be awestruck facing the problem. While there may be bugs on different platforms, bundler should support those too. It's not bundlers fault. And it might help gem-devs to be more aware of the cross platform developers if it's officially supported by bundler.
And it seems like to reach the second we have to sacrifice the first. But that should be the way to go, because as others already said: TL;DR: Support and document cross-platform-development and write a big |
My own opinion (for what it's worth) is that I can understand the unmet need here, and an opt-in feature to support cross-platform development would be a reasonable compromise. In practical terms, someone who has this need would need to commit to implementing, documenting and owning this feature long term. None of the currently active contributors to Bundler have this need and so we are not well-equipped to design this feature or support it. If our hunch is right that this would lead to a significant increase in issues filed against the project caused by misuse of the feature, we'd need help triaging and troubleshooting those issues as well. (The above could be said about most open feature requests, to be honest.) |
@TimMoore Well, that sounds reasonable. Could you quickly summarize why the |
@moeffju I'm not sure why the existing I think most of the logic would be in |
@TimMoore thank you for helping find a reasonable comprise here 🍻 |
Suggested steps towards a solutions: 1.) Add option to pretend to be on another platform than current. (we can resolve for multiple platforms without much pain) |
There should be an option at the top of your Gemfile Since this change is opt-in, it would not affect existing users. |
@coezbek there is no way to handle gems with different dependencies on different platforms, so that seems like a partial solution at best. :/ additionally, if you resolve a lock for a platform other than the platform you are on, you have never even tried executing the code that will be run when you deploy. you should be (at minimum) running @johnnyshields that's impossible, because some versions of nokogiri have completely different dependencies on different platforms. |
@indirect I guess I am getting closer to a conceptual understanding: You suggest that it is a bad smell when I want to lock down dependencies for another platform that I have not run on yet. My question is: How can I run on another platform without Again the question: How do I resolve for another platform, so I can actually try the code / run the tests on this platform? |
You don't at the moment -- you just delete the lock and run |
@coezbek wait, are you saying that you don't run The most practical solution that I am currently aware of to this issue is to set versions as required in your Gemfile, and then generate a new lock for your deployment platform as part of your CI process. It's not great, but we don't have any better solutions yet. |
No Gemfile.lock unless this gets resloved. rubygems/bundler-features#4
Here's a workaround that I quite like. It allows you to specify the platforms you don't want to stage Gemfile.lock files for, and unstages them on commit. Benefits:
Drawbacks:
|
Would love to see a solution to this as we develop on a Windows platform but have a need to vendor Linux gems. The workaround is to go on to a Linux box, bundle on the Linux box and copy the files back to the Windows machine. |
Closing in favor of rubygems/bundler#4517, please continue discussion there! |
Just curious, but why? This issue has all the discussion history. |
@phemmer we are going to archive this repository, keeping it active in addition to bundler/bundler would require me to duplicate all the labels / milestones. Also having the features exist in a different repo from the bug reports is confusing to users (including myself, a few days ago). |
As of now, I am yet to find a way to make
|
Simplest statement of problem: Allow windows developers to easily deploy to linux without having to do weird things to their lock file.
See rubygems/bundler#646 and rubygems/bundler#2040 for history, discussion, and some pointers for possible implementation.
The text was updated successfully, but these errors were encountered: