cms-sw / cms-git-tools

CMS Git Helpers
34 stars 26 forks source link

Do not force create CMSSW_BASE/src #120

Closed smuzaffar closed 2 years ago

smuzaffar commented 2 years ago

git cms-init is always creating $CMSSW_BASE/src. This means if one has deleted the CMSSW_BASE after setting the env and run git cms-init then it will create $CMSSW_BASE/src again. This PR proposes to create $CMSSW_BASE/src if not exists and only create src if $CMSSW_BASE already exists.

cmsbuild commented 2 years ago

A new Pull Request was created by @smuzaffar (Malik Shahzad Muzaffar) for branch master.

@cmsbuild, @smuzaffar, @iarspider, @ddaina can you please review it and eventually sign? Thanks. @perrotta, @dpiparo, @qliphy you are the release manager for this. cms-bot commands are listed here

cmsbuild commented 2 years ago

Pull request #120 was updated.

fwyzard commented 2 years ago

But it will fail with an error. Is it intended ?

smuzaffar commented 2 years ago

yes it should fail. If env points to a non-existing dev area then it should fail.

smuzaffar commented 2 years ago

This is to avoid the issues like the following

cd /tmp/$(whoami)`
scram p CMSSW_12_0_1_pre4
cd CMSSW_12_0_1_pre4
cmsenv
# CMSSW_BASe points to /tmp/$(whoami)/CMSSW_12_0_1_pre4
cd ..
rm -rf CMSSW_12_0_1_pre4
scram p CMSSW_12_0_1_pre3
cd CMSSW_12_0_1_pre3
git cms-addpkg FWCore

Currently this does not fail and user assumes that package has been checked out in his current project area but instead actually git-cms-init has created /tmp/$(whoami)CMSSW_12_0_1_pre4/src again

fwyzard commented 2 years ago

Mhm, I see.

However it would catch something very simple like

cd /tmp/$(whoami)`
scram p CMSSW_12_0_1_pre4
cd CMSSW_12_0_1_pre4
cmsenv
# CMSSW_BASe points to /tmp/$(whoami)/CMSSW_12_0_1_pre4
cd ..
scram p CMSSW_12_0_1_pre3
cd CMSSW_12_0_1_pre3
git cms-addpkg FWCore
fwyzard commented 2 years ago

Maybe we could (also) add a check to the git cms-... commands that they are being run inside $CMSSW_BASE/src ?

smuzaffar commented 2 years ago

yes it will not catch the issue if you set env from one area and then go to another and run git cms-. Correct fix would be to run cmsenv in the git cms- commands

fwyzard commented 2 years ago

Correct fix would be to run cmsenv in the git cms- commands

Mhm, ok, that would make sense, and it's consistent with how scram itself work:

cd /tmp/$(whoami)`
scram p CMSSW_12_0_1_pre4
cd CMSSW_12_0_1_pre4
cmsenv
# $CMSSW_BASE points to /tmp/$(whoami)/CMSSW_12_0_1_pre4

cd /tmp/$(whoami)`
scram p CMSSW_12_0_1_pre3
cd CMSSW_12_0_1_pre3
...
scram b

will build in /tmp/$(whoami)/CMSSW_12_0_1_pre3, even is $CMSSW_BASE points to a different area.