Giter VIP home page Giter VIP logo

Comments (35)

mpapis avatar mpapis commented on June 29, 2024

also consider using http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x264.html instead to avoid cd overwrite conflicts.

from chruby.

postmodern avatar postmodern commented on June 29, 2024

I assume you'd do something like PROMPT_COMMAND="chruby_auto; $PROMPT_COMMAND"? Other than the fact the command runs on every new prompt (meaning chruby_auto would have to return quickly if no action is needed), are there any other drawbacks?

from chruby.

mpapis avatar mpapis commented on June 29, 2024

I think yes, to speed up you can do:

export last_chruby_pwd=""
chruby_auto_prompt(){
  [[ "$last_chruby_pwd" == "$PWD" ]] || {
    chruby_auto
    last_chruby_pwd="$PWD"
  }
}

from chruby.

steveklabnik avatar steveklabnik commented on June 29, 2024

👍

from chruby.

postmodern avatar postmodern commented on June 29, 2024

Now using precmd_functions and PROMPT_COMMAND. This has the added benefit of automatically detecting new .ruby-version files after git pull or user creation.

from chruby.

ku1ik avatar ku1ik commented on June 29, 2024

Can't wait for it!

from chruby.

postmodern avatar postmodern commented on June 29, 2024

Coming in 0.3.0. But first I need to release 0.2.5, with a brand new setup.sh and installation instructions that don't rely on @github's deprecated Downloads. Also still have to write extensive tests for auto-switching.

from chruby.

mpapis avatar mpapis commented on June 29, 2024

just added rvm/rvm#1388 - works great

from chruby.

wilmoore avatar wilmoore commented on June 29, 2024

Just commented on one of the tests.

from chruby.

postmodern avatar postmodern commented on June 29, 2024

Copy/pasting my comment so no one missing it.

To avoid ascending each directory in search of a .ruby-version (I assume this would degrade performance) after every command, I decided to require the user cd into the project root.

Thoughts?

from chruby.

mpapis avatar mpapis commented on June 29, 2024

descending directories should not have any impact on performance, unix/linux does cache filesystem calls, so first call to a new directory might be slightly slower (like double disk seek time) but otherwise it's fast - tested it with RVM - you do not see the difference

from chruby.

postmodern avatar postmodern commented on June 29, 2024

Alright, I will add an ascending search for .ruby-version, if RUBY_VERSIONED_DIR isn't already set.

from chruby.

postmodern avatar postmodern commented on June 29, 2024

OK, I think I covered all the edge-cases. Please review.

from chruby.

postmodern avatar postmodern commented on June 29, 2024

Hmm, @github didn't auto-link to commit bf69302. Link to source and tests.

from chruby.

wilmoore avatar wilmoore commented on June 29, 2024

"${dir%/*}" 👍

That said; I couldn't figure out how this protects from infinitely looping once / is reached.

from chruby.

mpapis avatar mpapis commented on June 29, 2024

assertNull in shell ;)

from chruby.

postmodern avatar postmodern commented on June 29, 2024

Realized that the current implementation will not allow overriding the .ruby-version with an explicit call to chruby. Is this acceptable behaviour?

from chruby.

mpapis avatar mpapis commented on June 29, 2024

I do not thinks so, it's quite important to allow switching to something else, especially to try other rubies with your project

from chruby.

postmodern avatar postmodern commented on June 29, 2024

Next question, if a user explicitly selects a Ruby, should entering a project with a .ruby-version file override the already selected Ruby. Trying to avoid a chicken & egg problem between chruby and chruby_auto.

from chruby.

steveklabnik avatar steveklabnik commented on June 29, 2024

I would want entering the directory to set it to the version in .ruby-version regardless of what I've previously chosen.

from chruby.

postmodern avatar postmodern commented on June 29, 2024

Ah, my mistake. Due to the if [[ "$version_file" == "$RUBY_VERSION_FILE" ]]; then return check, we allow the user to override .ruby-version while within the project. I will sleep on this and then merge into the 0.3.0 branch, if there's no other comments.

from chruby.

pushcx avatar pushcx commented on June 29, 2024

I think .ruby-version is not the best name for this. It's a file specific only to chruby, and the contents are its name for your ruby (rather than some version specification that gets mapped to your ruby). In the future, it might have more info and thus be even less human-readable and generic.

I'd like to suggest .chruby or .chruby-version, similar to .rvm and .rbenv. I can put together a pull request if folks think this is a good idea and prefer one.

(And since this is the first time I've popped up on the project; thanks for making chruby, I switched a few days ago and have been really enjoying it.)

from chruby.

steveklabnik avatar steveklabnik commented on June 29, 2024

Isn't .ruby-version supported by both rvm and rbenv?

from chruby.

mpapis avatar mpapis commented on June 29, 2024

.ruby-version is supported by rvm and rbfu, there is a ticket for rbenv rbenv/rbenv#199 / rbenv/rbenv#201

from chruby.

postmodern avatar postmodern commented on June 29, 2024

I do agree that the name .ruby-version implies a specific version (which is tedious) compared to fuzzy matching against a canonical Ruby name (name-version). Adding a chruby specific dot-file would increase dot-file proliferation and promote factionalism amongst Rubyists; adding tool specific dot-files to repos is the developer equivalent of flying your colors.

from chruby.

pushcx avatar pushcx commented on June 29, 2024

I was totally unaware that was a shared standard, that's wonderful. I retract my suggestion. :)

from chruby.

ku1ik avatar ku1ik commented on June 29, 2024

I'm with @mpapis on ability to override version specified in .ruby-version with call to chruby. That's not uncommon use-case.

from chruby.

wilmoore avatar wilmoore commented on June 29, 2024

What should ruby -v be after the following scenario?

  • cd into a directory with a .ruby-version file, thus $(ruby -v) -eq "rubinius-2.0.0-rc1".
  • direct call chruby ruby-1.9.3 w/ fuzzy match; $(ruby -v) -eq "ruby-1.9.3-p327"
  • cd tests -- what should ruby -v be now?

from chruby.

mpapis avatar mpapis commented on June 29, 2024

@wilmoore I think it should be still what user picked in second step ruby-1.9.3-p327 - it should be reset only when user leaves context of current project / .ruby-version

from chruby.

wilmoore avatar wilmoore commented on June 29, 2024

it should be reset only when user leaves context of current project / .ruby-version

In the above scenario, when the user did cd tests, she moved from the root of the project to a descendant directory (still part of the project). That being the case, what takes precedent.

from chruby.

postmodern avatar postmodern commented on June 29, 2024

Here's an example of the current behaviour:

[hal@tank ronin]$ pwd
/vault/1/code/ronin
[hal@tank ronin]$ cat ronin/.ruby-version 
1.9
[hal@tank ronin]$ cd ronin
[hal@tank ronin]$ chruby
   jruby-1.7.0
   rubinius-2.0.0-rc1
 * ruby-1.9.3-p327
[hal@tank ronin]$ cd lib
[hal@tank lib]$ chruby
   jruby-1.7.0
   rubinius-2.0.0-rc1
 * ruby-1.9.3-p327
[hal@tank lib]$ chruby rubinius
[hal@tank lib]$ chruby
   jruby-1.7.0
 * rubinius-2.0.0-rc1
   ruby-1.9.3-p327
[hal@tank lib]$ cd ronin/ui/cli/
[hal@tank cli]$ chruby
   jruby-1.7.0
 * rubinius-2.0.0-rc1
   ruby-1.9.3-p327
[hal@tank cli]$ cd ../../../../
[hal@tank ronin]$ pwd
/vault/1/code/ronin/ronin
[hal@tank ronin]$ chruby
   jruby-1.7.0
 * rubinius-2.0.0-rc1
   ruby-1.9.3-p327
[hal@tank ronin]$ cd ..
[hal@tank ronin]$ chruby
   jruby-1.7.0
   rubinius-2.0.0-rc1
   ruby-1.9.3-p327

from chruby.

wilmoore avatar wilmoore commented on June 29, 2024

Appears to work as requested.

from chruby.

postmodern avatar postmodern commented on June 29, 2024

Without further ado, merging this into 0.3.0 branch.

from chruby.

postmodern avatar postmodern commented on June 29, 2024

Merged. Any pre-release comments/commits should be directed towards the 0.3.0 branch.

from chruby.

postmodern avatar postmodern commented on June 29, 2024

This has been released in 0.3.0.

from chruby.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.