lang/ruby: fix rbenv version detection

This commit is contained in:
Henrik Lissner 2018-07-06 23:58:11 +02:00
parent 0a577f3a0e
commit a0b0964355
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -35,13 +35,13 @@
(add-hook 'enh-ruby-mode-hook #'+ruby|add-version-to-modeline) (add-hook 'enh-ruby-mode-hook #'+ruby|add-version-to-modeline)
(if (not (executable-find "rbenv")) (if (not (executable-find "rbenv"))
(setq +ruby-current-version (string-trim (shell-command-to-string "ruby --version 2>&1 | cut -d' ' -f2"))) (setq-default +ruby-current-version (string-trim (shell-command-to-string "ruby --version 2>&1 | cut -d' ' -f2")))
(setq +ruby-rbenv-versions (split-string (shell-command-to-string "rbenv versions --bare") "\n" t)) (setq +ruby-rbenv-versions (split-string (shell-command-to-string "rbenv versions --bare") "\n" t))
(defun +ruby|detect-rbenv-version () (defun +ruby|detect-rbenv-version ()
"Detect the rbenv version for the current project and set the relevant "Detect the rbenv version for the current project and set the relevant
environment variables." environment variables."
(when-let* ((version-str (shell-command-to-string "ruby --version 2>&1 | cut -d' ' -f2"))) (when-let* ((version-str (shell-command-to-string "RBENV_VERSION= ruby --version 2>&1 | cut -d' ' -f2")))
(setq version-str (string-trim version-str) (setq version-str (string-trim version-str)
+ruby-current-version version-str) +ruby-current-version version-str)
(when (member version-str +ruby-rbenv-versions) (when (member version-str +ruby-rbenv-versions)