JoshCheek / atom-seeing-is-believing

Seeing is Believing integration for the Atom text editor.
Do What The F*ck You Want To Public License
62 stars 4 forks source link

Remove explicit ruby declaration #6

Closed deiga closed 10 years ago

deiga commented 10 years ago

Fixes #5

JoshCheek commented 10 years ago

Okay, thought about it a bit, and I'm pretty sure this can't work in a general sense. Meaning that if it works for you now, its both incidental, and the default settings should probably also work.

Without seeing your environment, there's a way to test this that's probably good enough (but not necessarily): Close Atom, relaunch it via Spotlight (not the console), does this still work? My hypothesis is that it does not, because this can only work if it is able to find the seeing_is_believing binary. And how does it find this? It's got to come from your environment variables, which are set-up in your shell, which atom inherits if you launch it from the shell, but not if you launch it from Spotlight.

The case where the test can be wrong is if you installed SiB in your system Ruby, and then it might be available without changing the environment.

But in a more general sense, this is not true for most people who use Ruby (because most people use rvm/chruby/rbenv).

Additionally, you should check out the default values (don't override anything in your ~/.atom/config.cson), they're basically the same thing as what you're doing here (make sure you have the latest version).

deiga commented 10 years ago

Ok, you are right that it can't find the binary. But the defaults don't work for rbenv because of the shim it creates. The shim is not a ruby script and thus passing it to ruby fails.

JoshCheek commented 10 years ago

Can you show me an example of what the shim looks like?

And just to make sure I understand how rbenv works: it installs your binary somewhere, then it puts an executable in a dir that is expected to be in the path (guessing the executable is written in sh) When the executable gets run, it figures out the correct environment and then goes and runs that program.


It seems like it should be able to work, because I used to use rbenv, and it worked for me, e.g.

The sublime settings are set up for rbenv by default, and it executes the code the same way.

So maybe something changed since then (ie shims used to be written in Ruby, but now are written in sh) or maybe there's something wonky with rbenv being installed at /usr/local/var/rbenv/ rather than ~/.rbenv/shims or maybe you've got something setup wrong.

It's just very strange to me that it can find the gem command here https://github.com/JoshCheek/atom-seeing-is-believing/issues/5#issuecomment-54065206, but not seeing_is_believing is gem not a shim, too?

deiga commented 10 years ago

Shim for seeing_is_believing (it's exactly the same as for gem)

cat $(which seeing_is_believing)                                                                                                                                                                                                                                eficode  3.2 4.3 3.5
#!/usr/bin/env bash
set -e
[ -n "$RBENV_DEBUG" ] && set -x

program="${0##*/}"
if [ "$program" = "ruby" ]; then
  for arg; do
    case "$arg" in
    -e* | -- ) break ;;
    */* )
      if [ -f "$arg" ]; then
        export RBENV_DIR="${arg%/*}"
        break
      fi
      ;;
    esac
  done
fi

export RBENV_ROOT="/usr/local/var/rbenv"
exec "/usr/local/Cellar/rbenv/0.4.0/libexec/rbenv" exec "$program" "$@"

I'll test the sublime package too, but I'm starting to think that somethings wrong with my setup. I just have no clue as to what :/

JoshCheek commented 10 years ago

Yeah, I really have no clue :( I can't get the same error you do (I'm using chruby these days), and I'm not thinking of anything that could explain all the things we see, I'd prob need to sit down and play in your env for an hour or two. If you're in Denver area, we can grab lunch and figure it out. I'll also be hitting up a few confs (Dcamp and RubyConf). In the meantime, it sounds like if you rely on your env vars being setup correctly that it works (or, alternatively, if you edit your bundle... not optimal, but at least it works, and the current integration is probably the best out of any editor, so should be good for quite a while).

deiga commented 10 years ago

Heh, Denver is quite far from Helsinki, Finland :P I think I'm going to open up an issue at rbenv and see if they can figure something out