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

Add fish support 🐟 #266

Merged
merged 9 commits into from
Feb 19, 2019
Merged

Add fish support 🐟 #266

merged 9 commits into from
Feb 19, 2019

Conversation

chriskrycho
Copy link
Contributor

@chriskrycho chriskrycho commented Feb 9, 2019

This PR builds on the work @scalvert started in #171 to add full fish support to Notion.

Testing

  1. Check out this branch locally. If you're using hub, hub pr checkout 266. (If you're not using hub… you should do that thing. And also alias it to git to make your life wonderful.)

  2. Create a release build: cargo build --release.

  3. Do the equivalent of running the install script: ./dev/unix/build.sh; and ./dev/unix/install.sh.

  4. Open a new shell, or refresh your current shell with the updated config: source ~/.config/fish/config.fish.

Then you should be able to use Notion!

@chriskrycho chriskrycho changed the title WIP: fish support Add fish support 🐟 Feb 12, 2019
@scalvert
Copy link
Contributor

@chriskrycho thank you, sir!

@chriskrycho
Copy link
Contributor Author

@scalvert @chadhietala @locks can you all do me a favor and make sure this works?

Testing

  1. Check out this branch locally. If you're using hub, hub pr checkout 266. (If you're not using hub… you should do that thing. And also alias it to git to make your life wonderful.)

  2. Create a release build: cargo build --release.

  3. Do the equivalent of running the install script: ./dev/unix/build.sh; and ./dev/unix/install.sh.

  4. Open a new shell, or refresh your current shell with the updated config: source ~/.config/fish/config.fish.

Then you should be able to use Notion!

Copy link
Contributor

@locks locks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works on my machine.

@chadhietala
Copy link

nod

@chadhietala
Copy link

I think there might be some issues with deactivate?

set: Warning: $PATH entry "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/:/Users/chietala/Code/binaryen/bin:/Users/chietala/.cargo/bin:/Users/chietala/.config/node/default/bin:/Users/chietala/.yarn/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/linkedin/bin:/export/content/linkedin/bin" is not valid (No such file or directory)
set: Did you mean 'set PATH $PATH /Users/chietala/Code/binaryen/bin:/Users/chietala/.cargo/bin:/Users/chietala/.config/node/default/bin:/Users/chietala/.yarn/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/linkedin/bin:/export/content/linkedin/bin'?

@chriskrycho
Copy link
Contributor Author

chriskrycho commented Feb 14, 2019

Ah, so, I think this is further up than the changes I made, but I know what the issue is: fish expects a path where entries are separated by spaces rather than :. The problem is the path as we're getting it in System (here). And that in turn is from yet further upstream, in envoy, which in turn just uses std::var_os.

I think, to make this do the right thing, I'll just need to add some special handling here, because what we have here is just what the OS reports back to us out of its getenv, so far as I can see. I'll double-check that analysis tomorrow, and add some special handling for it if so.

Should just be able to do something like path.replace(":", " ") when we're in fish, but I'm not sure whether locations can includes : if quoted.

See below!

@chriskrycho
Copy link
Contributor Author

chriskrycho commented Feb 14, 2019

@chadhietala an update on the above: I can't reproduce the error you're seeing, but also running notion activate or notion deactivate doesn't actually seem to be doing anything. 🤔

@chriskrycho
Copy link
Contributor Author

That path style actually seems to be fine; the real issue is that we're not quoting the value properly! I.e. this is part of #99.

@chriskrycho
Copy link
Contributor Author

chriskrycho commented Feb 14, 2019

@chadhietala the latest commit I pushed should have fixed it (as well as, you know, just making activate and deactivate do what they should) – can you test again and confirm?

@scalvert
Copy link
Contributor

Checking!

@chadhietala
Copy link

chadhietala commented Feb 14, 2019

No dice.
screen shot 2019-02-14 at 9 25 49 am

I think everything might be hosed from when I tried to deactivate last time. Where does Notion write these shell files? I looked at ~/.config/fish/config.fish does it write anywhere else? I get this same Warning message whenever I open another shell.

I was on a very old version of Fish.

@chriskrycho
Copy link
Contributor Author

Interesting. The quoting should have fixed this. 🤔

It's not writing it to anywhere in the deactivate/activate phase; it's just changing what the exported PATH value is for the shell and any children.

@chriskrycho
Copy link
Contributor Author

@chadhietala and I did some digging, and the issue around notion deactivate is that versions of fish earlier than 3.0 complain if you attempt to set a value of PATH (except, apparently, in .config/fish/config.fish?) that includes a non-existent/non-directory location, it prints a warning, exits with status 1, and does not update the PATH. Fish 3.0.0 changed this behavior so it works correctly.

This isn't something Notion can (or even should) control or work around: the exact same thing happens if you just run set -x PATH on the CLI with an invalid location on older versions of fish.

As such, the best solution here seems to be documentation: let users know that the two solutions are:

  • to edit their PATH in their ~/.config/fish/config.fish file to remove any items which do not exist on their system
  • to upgrade to fish ^3.0

@dherman, thoughts on where exactly we should document that? I was thinking in the notion activate and notion deactivate docs, since that's where this comes up?

@charlespierce
Copy link
Contributor

@chriskrycho Would it be possible to add something to the load.fish script that checks the exit code after source $NOTION_POSTSCRIPT and print a message if it finds a 1 there? That would be closest to the actual issue and would let a user know after they run notion activate or notion deactivate that it didn't work and they'll need to make changes

@chriskrycho
Copy link
Contributor Author

We’d have to put it in the fish postscript itself, actually; I considered that but wasn’t sure how much value that adds vs. just documenting it clearly and searchably. Let me experiment with doing just that and see how it comes out.

@chriskrycho
Copy link
Contributor Author

Okay, I've made that change and it looks like this:

screen shot 2019-02-14 at 13 36 40

Wording changes and formatting suggestions very welcome!

@scalvert
Copy link
Contributor

Everything is fine until the post-install step. Sourcing ~/.config/fish/config.fish doesn't result in notion having been added to my path. If I cat ~/.config/fish/config.fish, it's unmodified. I would have expected notion's install to modify it.

@chriskrycho
Copy link
Contributor Author

Weird. It worked fine for me and others; I will follow up with you in the morning!

@chriskrycho
Copy link
Contributor Author

@scalvert and I synced up; the problem here was that his $SHELL was /etc/bash instead of fish. It did correctly set up his bash profile! Once he updated his shell everything Just Worked™.

@scalvert
Copy link
Contributor

So the issue I had ended up being that my default shell was bash. So, the install was assuming, via the $SHELL env var, that I was using bash, not fish. I use iTerm2, and have it configured to run fish, which is why my env var wasn't set.

Setting $SHELL to fish solved the install problem.

scalvert and others added 8 commits February 15, 2019 12:39
- We cannot use `fish_user_paths`, nice though that would be, because it
  does not work correctly with our *unset* logic: the `PATH` we set up
  during installation in the user's profile stays there regardless of
  what we do with `fish_user_paths`.

- We need to properly quote the string we render into the `PATH` value
  so that when a user has a path entry which has e.g. spaces in it, it
  works correctly when fish validates it.
@charlespierce charlespierce merged commit 152e8c4 into volta-cli:master Feb 19, 2019
@stefanpenner
Copy link
Contributor

🕺

@chriskrycho chriskrycho deleted the fish-support branch February 19, 2019 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fish support
7 participants