Giter VIP home page Giter VIP logo

Comments (19)

dsifford avatar dsifford commented on June 9, 2024 1

I'll try in on my macbook here in the next hour or so and see if it's a mac quirk or something.

from yarn-completion.

dsifford avatar dsifford commented on June 9, 2024 1

@kachkaev I have no idea why this isn't working for you. I just matched all my shell options to the ones you have enabled and it still works perfectly fine on my end.

The only thing I can think of that it might still be is that you're using BSD sed. If you can confirm that the issue is still persisting even using GNU sed, then I'm out of ideas and will have to unfortunately wait until more people report this issue.

from yarn-completion.

kachkaev avatar kachkaev commented on June 9, 2024 1

Thanks for for your hint about GNU sed – turns out this is exactly what caused trouble! Originally, even after installing GNU bash, man sed was starting like:

screen shot 2018-02-24 at 19 11 57

Β Β 

After I did brew install gnu-sed --with-default-names and restarted the Terminal, it changed to:

screen shot 2018-02-24 at 19 11 42

Consequently, yarn autocompletion 0.6.0 began to work! πŸŽ‰

I'm a frequent user of the command line, but am no way an expert in bash versions and flavours of other standard tools. All this is pretty foggy to me, so thanks for your help with sorting things out! To summarise, this is what I had to do in order to get yarn-completion on macOS High Sierra working:

brew install bash
brew install gnu-sed --with-default-names

brew install bash-completion
## + copy a few commands to ~/.bash_profile as instructed by brew after bash-completion setup

curl -L https://raw.githubusercontent.com/dsifford/yarn-completion/master/yarn-completion.bash > `brew --prefix`/etc/bash_completion.d/yarn

## restart Terminal

Hope this helps someone else in a similar situation!

from yarn-completion.

dsifford avatar dsifford commented on June 9, 2024 1

Urrrrgh! BSD utils are going to be the death of me, I swear....

Glad to hear we've found the culprit. I'll try and get this compatible with BSD as soon as feasible. Thanks for your patience.

from yarn-completion.

dsifford avatar dsifford commented on June 9, 2024 1

Version 0.6.1 should work in BSD sed now.

from yarn-completion.

dsifford avatar dsifford commented on June 9, 2024

Very likely.

The way the JSON is parsed out for script names is pretty archaic since the goal is to keep it portable across platforms.

Happy to take a PR on it if you feel like making the parsing with sed work better

from yarn-completion.

kachkaev avatar kachkaev commented on June 9, 2024

I'm pretty sure I won't be able to crack it in any reasonable time because my level in bash script editing in 0.01 out of 1 πŸ˜…

Speaking of a a simple fix, could a RegExp that searches for the end of "scripts" look like so?

  • we terminate if there is } and it is at the end of a line (whitespacing ignored)
  • we terminate if there is }, and it is either at the start or at the end of a line (whitespacing ignored)

This still won't be as clean as parsing json in full, but the likelihood of bugs should get smaller.

from yarn-completion.

dsifford avatar dsifford commented on June 9, 2024

@kachkaev This should be fixed now in 0.6.0.

from yarn-completion.

kachkaev avatar kachkaev commented on June 9, 2024

Thanks for trying to fix this @dsifford! It could be that I've done something wrong, but after updating to 0.6.0 script detection broke completely. I still see it working as it was in the pre-update terminal tabs, but in all new tabs I get:

yarn run β†’tab yarn run env
yarn β†’tab all standard yarn commands, no helloX commands

npm run still shows hello1 ... hello5 as it should.

I tested 0.6.0 on a couple of real-world packages in addition to the MWE above and the problem reproduced in all cases.

What could be causing this in brew's bash 4.4.19(1)-release (x86_64-apple-darwin17.3.0) with yarn-completion 0.6.0 also installed via homebrew?

from yarn-completion.

dsifford avatar dsifford commented on June 9, 2024

Not sure. I tried all the examples you provided when I made the change and it worked for me.

And actually, the change I made to the sed command made it even more POSIX compliant than the earlier one (the earlier one used extended regexp).

Did you try logging out completely and logging back in to make sure you weren't using a stale file or something?

from yarn-completion.

kachkaev avatar kachkaev commented on June 9, 2024

Same behaviour even after a full reboot. Curious to know what your mac test tells you! Thanks a lot for looking into this problem πŸš€

from yarn-completion.

dsifford avatar dsifford commented on June 9, 2024

Thanks for checking.

Do you have a repo that has a non-parsable package.json file that I can clone when I test on my macbook? I want to be certain that I'm reproducing this correctly.

from yarn-completion.

dsifford avatar dsifford commented on June 9, 2024

@kachkaev Cant reproduce on my macbook.

Tried it using the package.json in this repo and it worked just fine for me: https://github.com/callthemonline/client-nextjs

from yarn-completion.

dsifford avatar dsifford commented on June 9, 2024

Also, I just tried it again using both GNU and BSD sed and it still worked for me.

I assume you have the default BSD sed installed on your system? Can you try installing GNU sed and see if that works?

from yarn-completion.

dsifford avatar dsifford commented on June 9, 2024

@kachkaev what's the output when you enter shopt -p | sort?

from yarn-completion.

kachkaev avatar kachkaev commented on June 9, 2024

screen shot 2018-02-24 at 07 54 27

Downgrading to 0.5.1 by running

curl -L https://raw.githubusercontent.com/dsifford/yarn-completion/c40137136d8b803407f5f2fb99c1ae92af594b07/yarn-completion.bash > `brew --prefix`/etc/bash_completion.d/yarn

returns yarn-completion to its old behaviour described in this issue (after Terminal is relaunched, of course). This means that my setup is not broken as such and it's not the case of me having using two conflicting yarn completions somehow.

Upgrading one commit up to 3b5a4d7 makes things as broken as on current master (0.6.0), i.e. I only see yarn run β†’ run yarn env. The behaviour is the same both for https://github.com/callthemonline/client-nextjs and a dummy project where package.json just contains hello1...5 scripts.

from yarn-completion.

kachkaev avatar kachkaev commented on June 9, 2024

Feel free to supplement README with my setup commands. I can easily imagine someone else getting into a similar trouble, so it’ll be great if we can save their time!

from yarn-completion.

dsifford avatar dsifford commented on June 9, 2024

Open a PR with the edits and I'll be happy to merge

from yarn-completion.

kachkaev avatar kachkaev commented on June 9, 2024

Thank you! 0.6.1 worked for me even after uninstalling gnu-sed πŸŽ‰

from yarn-completion.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.