Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Env autoactivate doesn't work when "name" in environment.yml is a posix path #161

Open
GrqPnegre opened this issue Aug 28, 2024 · 0 comments
Labels

Comments

@GrqPnegre
Copy link

Looks like conda--get-name-from-env-yml isn't parsing POSIX paths properly.

Steps to reproduce

$ emacs --version
GNU Emacs 30.0.50
Development version a470dfb7f8a0 on master branch; build date 2024-01-30.
(pkg-info-package-version 'conda)
(20240708 2135)
mkdir -P ~/p/del/myproject
cd ~/p/del/myproject

conda create --prefix ./envs pyqt6
conda activate ./envs
conda env export > environment.yml
conda deactivate
~/p/del/myproject$ head -1 environment.yml
name: /home/someuser/p/del/myproject/envs
  • Launch emacs
  • find-file ~/p/del/myproject/environment.yml
  • switch from/to the buffer (environment doesn't change)

Possible fix for POSIX paths

Add forward slash to regex in conda--get-name-from-env-yml.

(defun conda--get-name-from-env-yml (filename)
  "Pull the `name` property out of the YAML file at FILENAME."
  ;; TODO: find a better way than slurping it in and using a regex...
  (when filename
    (let ((env-yml-contents (f-read-text filename)))
      (if (string-match "name:[ ]*\\([A-z0-9-_./]+\\)[ ]*$" env-yml-contents)
          (match-string 1 env-yml-contents)
        nil))))
@necaris necaris added the bug label Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants