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

bit eject fail, Command failed: git checkout 1.1.27 #1578

Closed
oahehc opened this issue Apr 26, 2019 · 6 comments
Closed

bit eject fail, Command failed: git checkout 1.1.27 #1578

oahehc opened this issue Apr 26, 2019 · 6 comments

Comments

@oahehc
Copy link

oahehc commented Apr 26, 2019

Expected Behavior

eject success

Actual Behavior

eject fail with this error message: Command failed: git checkout 1.1.27

Steps to Reproduce the Problem

  1. I have a dependency on package.json look like this:
    "my-library": "https://bitbucket.org/my-library.git#1.1.27",
  2. execute bit eject
  3. Command failed: git checkout 1.1.27

(I don't have 1.1.27 branch, so I guess the eject command was misguided by the dependency's format?)

Specifications

  • Bit version: v14.0.6
  • Node version: v8.11.4
  • yarn version: v1.13.0
  • Bit compiler (include version): /bit.envs.compilers.react-typescript@3.0.0
  • Bit tester (include version): N/A

Thanks for the help in advance.

@GiladShoham
Copy link
Member

@oahehc That indeed looks like the eject was misguided by the dependency's format as you said.
The eject final step is to run npm/yarn install to install the component as a regular package.
This, of course, might lead to install other dependencies.
Where is this dependency defined? in the component's package.json or in the project pacakge.json?
Does npm install (without bit) for this pacakge.json / dependency is working?

@oahehc
Copy link
Author

oahehc commented Apr 28, 2019

Hi @GiladShoham
Where is this dependency defined?
Ans: in the project pacakge.json

Does npm install (without bit) for this pacakge.json / dependency is working?
Ans. Yes, it will do something like npm i https://bitbucket.org/my-library.git#1.1.27 to install this library.

@davidfirst
Copy link
Member

Hi @oahehc ,
I was working to reproduce the issue. I created a new repo on my Bitbucket account, generated a new tag, added to my package.json in the same format you have (https not ssh), exported a new component and then I was running bit eject component-id, it was working with no issues. It was able to run npm install of the project package.json file.
I was also trying to use the same node version as yours (v8.11.4), still no luck.

If you can provide a reproduce tar/zip, it'd be great. (you can send it to david@bit.dev).

@oahehc
Copy link
Author

oahehc commented May 2, 2019

Hi @davidfirst
Thanks for the help.
I created a test repo and bit collection.
Follow the steps below should be able to reproduce the error.
I guess it might be related to the name of repo and bit collection which have the same prefix.

  1. create a new project:
    • mkdir [project-name]
    • cd [project-name]
    • yarn init -y
  2. install package:
  3. import bit component:
    • bit init
    • bit import oahehc.bit-component-test/index
  4. eject bit component:
    • bit eject index

Error Message:

eject failed installing the components using the NPM client.
your package.json (if existed) has been restored, however, some bit generated data may have been deleted, please run "bit link" to restore them.

got the following error: failed running npm install at /Users/andrew/Documents/andrew/_test/test2
npm ERR! code 1
npm ERR! Command failed: git checkout 1.0.0
npm ERR! error: pathspec '1.0.0' did not match any file(s) known to git.
npm ERR!

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/andrew/.npm/_logs/2019-05-02T00_38_36_681Z-debug.log

@davidfirst
Copy link
Member

@oahehc thank you for the detailed explanation, it was super easy for me to reproduce :)

The problem here is a combination of two things.

  1. that's the surprising part: yarn and npm interpret #1.0.0 differently.
    In your case, the tag name in Git is "v1.0.0", with the prefix "v", that's why NPM throws an error. You can reproduce it easily regardless of Bit by running npm install https://github.com/oahehc/bit-test\#1.0.0, it throws the error you got before. The reason is that NPM tries to git checkout 1.0.0, which doesn't exist. Changing it to npm install https://github.com/oahehc/bit-test\#v1.0.0 (with the prefix v) works just fine.
    Yarn, however, interpret it as bit-test@1.0.0. That's why with Yarn you don't get any error.

  2. Bit by default uses NPM as the package manager. Since you use yarn to install your packages, it'll make sense to you to change the Bit settings to use yarn.
    It's easy, just open your package.json (or bit.json) and replace this: "packageManager": "npm" with "packageManager": "yarn".

I tried both, changing from '1.0.0' to 'v1.0.0' and changing from 'npm' to 'yarn', both work.

@oahehc
Copy link
Author

oahehc commented May 3, 2019

@davidfirst
Thanks a lot.
eject successfully after replacing packageManager to yarn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants