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

crashing on test mode #2

Open
mromanuk opened this issue May 6, 2020 · 19 comments
Open

crashing on test mode #2

mromanuk opened this issue May 6, 2020 · 19 comments
Assignees

Comments

@mromanuk
Copy link

mromanuk commented May 6, 2020

I tried to run your script in test mode, but it is crashing:

BEAR_TEST=true \
> /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/cglacet/bear/master/install.sh)"
That's the first time you run this script.
Retreiving source from Github (https://github.com/cglacet/bear).
fatal: ambiguous argument 'remotes/origin/HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Updating source from Github (https://github.com/cglacet/bear).
Adding back-reference links to your Bear notes
----------------------------------------------
python: can't open file 'insert_backreferences.py': [Errno 2] No such file or directory
@klickreflex
Copy link

klickreflex commented May 6, 2020

I'm getting a similar error on test mode:

BEAR_TEST=true \
➜ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/cglacet/bear/master/install.sh)"
That's the first time you run this script.
Retreiving source from Github (https://github.com/cglacet/bear).
Adding back-reference links to your Bear notes
----------------------------------------------
  File "insert_backreferences.py", line 26
    print(f"Inserted {nb_links_inserted} new links to your notes.")
                                                                 ^
SyntaxError: invalid syntax

It fails in non-test mode, too:

 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/cglacet/bear/master/install.sh)"

Adding back-reference links to your Bear notes
----------------------------------------------
  File "insert_backreferences.py", line 26
    print(f"Inserted {nb_links_inserted} new links to your notes.")
                                                                 ^
SyntaxError: invalid syntax

I have Python 3.7.7 via brew on MacOS 10.15.4

@cglacet
Copy link
Owner

cglacet commented May 6, 2020

@mromanuk can you try again? Just to make sure use this version:

BEAR_TEST=true /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/cglacet/bear/61e00fc226afb5781878548185fdc62cdefd3ff0/install.sh)"

I've updated a bit widely as I had no idea if anyone was testing this. I'll keep things clean in master now 👍 (let me know if this works).

@cglacet
Copy link
Owner

cglacet commented May 6, 2020

@klickreflex That's strange, what happens if you run the following:

python -c "nb_links_inserted=3; print(f'Inserted {nb_links_inserted} new links to your notes.')"

It may be because I call python in the installation script and you also have an older version of python binded to it. What's the output of python --version?

@cglacet cglacet self-assigned this May 6, 2020
@klickreflex
Copy link

klickreflex commented May 7, 2020

@cglacet running python -c "nb_links_inserted=3; print(f'Inserted {nb_links_inserted} new links to your notes.')" returns the expected result:

Inserted 3 new links to your notes.

python --version returns: Python 3.7.6 (and 3.7.7 on another machine).

which python returns: python: aliased to /usr/local/bin/python3

Thanks for your help :)

@klickreflex
Copy link

klickreflex commented May 7, 2020

If I remove the alias that link python to python 3 I get:

➜ python --version
Python 2.7.16

~
➜ which python
/usr/bin/python


➜ BEAR_TEST=true \
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/cglacet/bear/master/install.sh)"
Updating source from Github (git@github.com:cglacet/bear.git).
Adding back-reference links to your Bear notes
----------------------------------------------
  File "/Users/daniel/.github/bear/back-references/insert_backreferences.py", line 28
    print(f"Inserted {nb_links_inserted} new links to your notes.")
                                                                 ^
SyntaxError: invalid syntax

Background: I've had the following alias in my .zshrc file because Python 3 installed via brew is only available via the python3 command: alias python=/usr/local/bin/python3 (following this guide)

@cglacet
Copy link
Owner

cglacet commented May 7, 2020

@klickreflex I used to pull my hairs off with python versions then I started using pyenv never had any problem since (the article you linked also suggest not bothering with python versions and use pyenv instead).

Since you have an alias maybe the following doesn't give the same version as straight python --version?

❯ /bin/bash -c "python --version"

If that's the case pyenv would solve that problem too and you would have the same python version in both cases:

❯ python --version ; /bin/bash -c "python --version"
Python 3.8.2
Python 3.8.2

❯ pyenv global 3.7.7

❯ python --version ; /bin/bash -c "python --version"

Python 3.7.7
Python 3.7.7

I guess your system python version is still a python 2 which causes problems with the "new" print (I could import __future__ but since python 2 is not supported anymore I probably wont).

With the alias you have, your python version of choice is only linked to your shell (zsh). If you start using pyenv, I would suggest removing any alias you have on python interpreters, just in case:

alias python=echo ; python --version ; /bin/bash -c "python --version"

--version
Python 3.7.7

@klickreflex
Copy link

@cglacet Awesome, this was the problem, my system Python got called. Pyenv solved it, thanks for recommending it. Should have done this long time ago, Python versioning is so confusing.

Now I'm still having trouble getting the expected references into my notes, but maybe I'm using it wrong. Will check again in the evening.

@cglacet
Copy link
Owner

cglacet commented May 7, 2020

You could also install everything manually if you already have git and python, most of the install script is made to install these (and made for non-developpers, I should add a line for developpers), the rest of it is more or less equivalent to this:

git clone git@github.com:cglacet/bear.git
cd bear
BEAR_TEST=true python insert_backreferences.py

@cglacet
Copy link
Owner

cglacet commented May 7, 2020

@klickreflex

Python versioning is so confusing

Yes, the xkcd drawing is pretty accurate 😛

@mromanuk
Copy link
Author

mromanuk commented May 7, 2020

You could also install everything manually if you already have git and python, most of the install script is made to install these (and made for non-developpers, I should add a line for developpers), the rest of it is more or less equivalent to this:

git clone git@github.com:cglacet/bear.git
cd bear
BEAR_TEST=true python insert_backreferences.py

it works! thanks!

@cglacet
Copy link
Owner

cglacet commented May 7, 2020

@mromanuk Great! let me know if you try it on your notes. Don't forget to backup before, just in case 🦺.

One problem I can't solve for now is the modification date of updated notes will be set to "now". Which I find sad as adding back reference shouldn't be considered a modification in the note, but the API from Bear doesn't allow to modify a note without altering the modification date.

@mromanuk
Copy link
Author

mromanuk commented May 7, 2020

@mromanuk Great! let me know if you try it on your notes. Don't forget to backup before, just in case 🦺.

One problem I can't solve for now is the modification date of updated notes will be set to "now". Which I find sad as adding back reference shouldn't be considered a modification in the note, but the API from Bear doesn't allow to modify a note without altering the modification date.

it worked like a charm 🙌

@cglacet
Copy link
Owner

cglacet commented May 7, 2020

@mromanuk ah, very good news, so you and I are the only two person to have used it successfully so far. You doubled the number of successes 🤣!

@benjaminharr
Copy link

I have the very same issue, however can't follow your suggested solution with pyenv. After installation I still get the mac os default version of 2.7.x displayed with python --version.

Help is needed 🙋‍♂️

@chnadell
Copy link

chnadell commented May 8, 2020

I confirmed this also works with a virtualenv environment activated--the correct python interpreter gets called

@benjaminharr
Copy link

benjaminharr commented May 8, 2020

Could also get it to work after digging into the implementation notes. Can't believe I haven't figured this out earlier: Instead of using the 'Link to note' feature I've always used the wiki-style links with [[page]] and was wondering why there are no links created.

Is there any way to include wiki-style links as well? For me those are a lot handier, since I can simply create a new page without manually creating one and getting the link of it. I wouldn't mind the reference links to be in the bear-style in order to avoid the circle reference described in your implementation notes.

@cglacet
Copy link
Owner

cglacet commented May 9, 2020

@benjaminharr Once you have installed pyenv you also need to use it to install a newer version of python and then set this version as the global version. For example with python 3.7.7:

pyenv install 3.7.7
pyenv global 3.7.7 

Concerning wiki-style links I don't know what they are so I can't tell you for now 😛. But I can have a look at that. By the way how did you installed python on your machine? I think the auto-install script I wrote is not good. It should install a newer version of python I think.

Thanks for the feedback.

@cglacet
Copy link
Owner

cglacet commented May 9, 2020

I modified the installation script, now it should install pyenv and a more recent version of python (python 2 is not supported anymore). Then it should set a local python environment in the cloned repository and run the script. The previous version only checked for an existing python install, which was not really useful as most people have python installed even though they don't really maintain it up to date :).

Hopefully this should work and be more or less equivalent to running:

mkdir -p ~/.github/bear/back-references
cd ~/.github/bear/back-references
git clone git@github.com:cglacet/bear.git .

brew install pyenv
pyenv install 3.7.7
pyenv local 3.7.7

Which should be enough to run the script, for example:

BEAR_TEST=true python insert_backreferences.py

If you plan on using python yourself, you could also run pyenv global 3.7.7 which will set a more recent version of python to be used system wide. That can't shouldn't hurt.

@benjaminharr
Copy link

Thanks for giving the additional info on pyenv, have managed to set it up and have a global updated version by now!

Concerning wiki-style links: there are two ways to link notes in bear.

  1. Link to notes, manually to be created via right click in the notes list -> copy link
  2. 'Auto-complete' links as they call them. Entering [[ within a note will start searching for note titles and link the respective note. If there is no such note it will create a new one.

I only use the later ones in my workflow, since I barely have the notes list visible and find it a lot more intuitive to link the pages this way.

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

No branches or pull requests

5 participants