bit eject fail, Command failed: git checkout 1.1.27

Created on 26 Apr 2019  路  6Comments  路  Source: teambit/bit

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.[email protected]
  • Bit tester (include version): N/A

Thanks for the help in advance.

areeject typbug

Most helpful comment

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

All 6 comments

@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?

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.

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 [email protected]).

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

@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 [email protected]. That's why with Yarn you don't get any error.
  1. 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.

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

viiralt picture viiralt  路  11Comments

KutnerUri picture KutnerUri  路  12Comments

seed-of-apricot picture seed-of-apricot  路  21Comments

FredyC picture FredyC  路  20Comments

jimmi-joensson picture jimmi-joensson  路  14Comments