rubyonjets / jets

Ruby on Jets
http://rubyonjets.com
MIT License
2.6k stars 181 forks source link

Build in tmp instead /tmp #313

Closed ChrisBr closed 5 years ago

ChrisBr commented 5 years ago

Checklist

My Environment

Software Version
Operating System osx
Jets master
Ruby 2.5.3

Expected Behaviour

Jets build command uses #{Jets.root.join('tmp') instead of /tmp directory. When using a different Ruby version (which is likely because jets does not support latest Ruby version so far), the project Ruby version does not match Ruby version in /tmp. This can cause several issues like different bundler version and missing system libraries. Build directory should use the same Ruby version as the development directory.

Current Behavior

Build directory is /tmp.

Code Sample

See the following example, when having a .ruby-version file, having a nested folder tmp rbenv will keep the same Ruby version, however, switching to tmp it will use the global system Ruby version which most likely will vary.

14:16  ChrisBr@Christians-MacBook-Pro ~/foo > cat .ruby-version 
2.6.3
14:16  ChrisBr@Christians-MacBook-Pro ~/foo > ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
14:16  ChrisBr@Christians-MacBook-Pro ~/foo > cd /tmp && ruby -v
ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin18]
14:16  ChrisBr@Christians-MacBook-Pro /tmp/tmp > h
14:16  ChrisBr@Christians-MacBook-Pro ~ > cd foo/
14:16  ChrisBr@Christians-MacBook-Pro ~/foo > mkdir tmp && cd tmp && ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
tongueroo commented 5 years ago

Originally, jets built it in PROJECT/tmp, but moved it to /tmp/jets/PROJECT because the build artifacts would show up when searching for code, which was too noisy. It wasn't as pleasant to search for code and then would end up deleting tmp. But then we would lose build cache, which was also not pleasant.

Would prefer to keep the build process in /tmp.

Got an idea to fix this ruby-version issue though. As part of the build process we can copy the .ruby-version file to /tmp/jets/PROJECT/.ruby-version. So if we cd into /tmp/jets/PROJECT the ruby version manager will switch to the same version of ruby.

At the /tmp level it'll use the ~/.ruby-version in the home folder still. So we can control it with ~/.ruby-version in that case.

Will take a PR for this. If not, will take a look at it in time.

ChrisBr commented 5 years ago

Originally, jets built it in PROJECT/tmp, but moved it to /tmp/jets/PROJECT because the build artifacts would show up when searching for code, which was too noisy. It wasn't as pleasant to search for code and then would end up deleting tmp. But then we would lose build cache, which was also not pleasant.

Hmm, isn't that anything which should get fixed on editor level?

Got an idea to fix this ruby-version issue though. As part of the build process we can copy the .ruby-version file to /tmp/jets/PROJECT/.ruby-version. So if we cd into /tmp/jets/PROJECT the ruby version manager will switch to the same version of ruby.

Yeah, that's also an solution which might be easier as well. However, still think that the build process should be in the project directory or at least configurable.

At the /tmp level it'll use the ~/.ruby-version in the home folder still. So we can control it with ~/.ruby-version in that case.

Yeah, that's how I eventually worked around it...

Will take a PR for this. If not, will take a look at it in time.

I will have a look at it.

tongueroo commented 5 years ago

RE: Hmm, isn't that anything which should get fixed on editor level?

Feel like users would have to take an unnecessary step of configuring their editor to ignore the search path. Some editors don’t support ignoring search paths as a feature also. 🤔

RE: Yeah, that's also an solution which might be easier as well. However, still think that the build process should be in the project directory or at least configurable.

Maybe. Unsure if it’s worth it to make it configurable at this time. If it’s configurable, then the default build root would be within /tmp. 🧐

RE: I will have a look at it.

👍