@@ -1328,14 +1328,16 @@ static int _main(int argc, char * * argv)
13281328 globals.instSource .systemFilter = " *" ;
13291329
13301330 if (!pathExists (globals.instSource .nixExprPath )) {
1331- createDirs (globals.instSource .nixExprPath );
1332- replaceSymlink (
1333- fmt (" %s/profiles/per-user/%s/channels" , settings.nixStateDir , getUserName ()),
1334- globals.instSource .nixExprPath + " /channels" );
1335- if (getuid () != 0 )
1331+ try {
1332+ createDirs (globals.instSource .nixExprPath );
13361333 replaceSymlink (
1337- fmt (" %s/profiles/per-user/root/channels" , settings.nixStateDir ),
1338- globals.instSource .nixExprPath + " /channels_root" );
1334+ fmt (" %s/profiles/per-user/%s/channels" , settings.nixStateDir , getUserName ()),
1335+ globals.instSource .nixExprPath + " /channels" );
1336+ if (getuid () != 0 )
1337+ replaceSymlink (
1338+ fmt (" %s/profiles/per-user/root/channels" , settings.nixStateDir ),
1339+ globals.instSource .nixExprPath + " /channels_root" );
1340+ } catch (Error &) { }
13391341 }
13401342
13411343 globals.dryRun = false ;
@@ -1430,14 +1432,18 @@ static int _main(int argc, char * * argv)
14301432
14311433 if (globals.profile == " " ) {
14321434 Path profileLink = getHome () + " /.nix-profile" ;
1433- if (!pathExists (profileLink)) {
1434- replaceSymlink (
1435- getuid () == 0
1436- ? settings.nixStateDir + " /profiles/default"
1437- : fmt (" %s/profiles/per-user/%s/profile" , settings.nixStateDir , getUserName ()),
1438- profileLink);
1435+ try {
1436+ if (!pathExists (profileLink)) {
1437+ replaceSymlink (
1438+ getuid () == 0
1439+ ? settings.nixStateDir + " /profiles/default"
1440+ : fmt (" %s/profiles/per-user/%s/profile" , settings.nixStateDir , getUserName ()),
1441+ profileLink);
1442+ }
1443+ globals.profile = absPath (readLink (profileLink), dirOf (profileLink));
1444+ } catch (Error &) {
1445+ globals.profile = profileLink;
14391446 }
1440- globals.profile = absPath (readLink (profileLink), dirOf (profileLink));
14411447 }
14421448
14431449 op (globals, opFlags, opArgs);
0 commit comments