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

hx --tutor or :tutor don't work when hx is symlink #3768

Closed
bnoordhuis opened this issue Sep 9, 2022 · 6 comments · Fixed by #3794
Closed

hx --tutor or :tutor don't work when hx is symlink #3768

bnoordhuis opened this issue Sep 9, 2022 · 6 comments · Fixed by #3794
Labels
C-bug Category: This is a bug

Comments

@bnoordhuis
Copy link
Contributor

Summary

The tutor doesn't work when hx is invoked through a symlink. The real path works.

Reproduction Steps

I tried this:

  1. download and untar helix to $HOME/opt/helix
  2. cd $HOME/bin && ln -s ../opt/helix/hx (~/bin is on the PATH)
  3. hx --tutor

I expected this to happen:

See the tutorial. :-)

Instead, this happened:

Nothing. Empty buffer.

Helix log

No log file was written.

Platform

macOS

Terminal Emulator

Terminal.app

Helix Version

helix 22.08.1 (66276ce)

@bnoordhuis bnoordhuis added the C-bug Category: This is a bug label Sep 9, 2022
@the-mikedavis
Copy link
Member

Does syntax highlighting work either when hx is a symlink? I think the symlink is breaking the detection of the runtime directory. You can set an explicit $HELIX_RUNTIME environment variable to the runtime directory path to fix it.

The tutor is loaded from the runtime directory:

let path = helix_loader::runtime_dir().join("tutor.txt");
editor.open(&path, Action::VerticalSplit)?;
// Unset path to prevent accidentally saving to the original tutor file.
doc_mut!(editor).set_path(None)?;

@bnoordhuis
Copy link
Contributor Author

Syntax highlighting indeed doesn't work.

I believe runtime_dir() ultimately falls back to std::env::current_exe()? Can I suggest running that through std::fs::canonicalize() to get the real path?

(I can try putting together a PR sometime next week.)

bnoordhuis added a commit to bnoordhuis/helix that referenced this issue Sep 11, 2022
When looking up the runtime/ directory relative to the executable path,
canonicalize the path first in case the executable is a symbolic link.

Fixes helix-editor#3768
@9glenda
Copy link

9glenda commented Sep 13, 2022

On my nixos install helix is also a symlink (like on every nixos install) and the tutor works
here info about my symlink:

[glenda@nixos:~]$ ls -lah $(which hx)
lrwxrwxrwx 1 root root 62 Jan  1  1970 /run/current-system/sw/bin/hx -> /nix/store/skpa4rd1h3s23b1h1v6y5rn58vq1zd5i-helix-22.08/bin/hx

If there are any issues with helix being a symlink nixos users will always suffer from them.

@the-mikedavis
Copy link
Member

Nix builds set the HELIX_RUNTIME environment variable (nixpkgs, this repo's flake)

CBenoit pushed a commit that referenced this issue Sep 13, 2022
When looking up the runtime/ directory relative to the executable path,
canonicalize the path first in case the executable is a symbolic link.

Fixes #3768
@rayhem
Copy link

rayhem commented Dec 9, 2022

I'm not sure if this is the same issue or just the same symptom because I'm super new to Helix, but I followed the build-from-source instructions on a Debian 11 machine (clone repo & $ cargo install --path helix-term, helix version d14de27) and I've not gotten hx --tutor to do anything meaningful. I've tried running both with and without links to helix, as well as running the executable directly with both relative and absolute pathing and the application only ever shows me an empty buffer. I'm happy to open a new issue with full details if this is only superficially related.

@the-mikedavis
Copy link
Member

If you installed from source, you need to link the runtime directory:

helix/README.md

Lines 60 to 67 in d14de27

Helix needs its runtime files so make sure to copy/symlink the `runtime/` directory into the
config directory (for example `~/.config/helix/runtime` on Linux/macOS, or `%AppData%/helix/runtime` on Windows).
| OS | Command |
| -------------------- | ------------------------------------------------ |
| Windows (Cmd) | `xcopy /e /i runtime %AppData%\helix\runtime` |
| Windows (PowerShell) | `xcopy /e /i runtime $Env:AppData\helix\runtime` |
| Linux / macOS | `ln -s $PWD/runtime ~/.config/helix/runtime` |

herkhinah pushed a commit to herkhinah/helix that referenced this issue Dec 11, 2022
When looking up the runtime/ directory relative to the executable path,
canonicalize the path first in case the executable is a symbolic link.

Fixes helix-editor#3768
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants