How does APM determine the currently installed Atom version?


#1

Hi,

I have built Atom on my Arch Linux machine, with the latest available APM version (1.11.4), and whenever I run apm update I get the error:

Could not determine current Atom version installed

Previously I had used APM 1.11.4 without this error, so I am wondering how I can fix this error. So where does APM get the currently-running Atom version? I have tried to fix this error by editing the lib/upgrade.js file (where lib/apm-cli.js is the JS script run by apm). Setting the version in:

    Upgrade.prototype.loadInstalledAtomVersion = function(options, callback) {
      if (options.argv.compatible) {
        return process.nextTick((function(_this) {
          return function() {
            var version;
            version = _this.normalizeVersion(options.argv.compatible);
            if (semver.valid(version)) {
              _this.installedAtomVersion = version;
            }
            return callback();
          };
        })(this));
      } else {
        return this.loadInstalledAtomMetadata(callback);
      }
    };

(i.e., I replaced this bit of code with:

    Upgrade.prototype.loadInstalledAtomVersion = function(options, callback) {
      if (options.argv.compatible) {
        return process.nextTick((function(_this) {
          return function() {
            var version;
            version = _this.normalizeVersion(options.argv.compatible);
            if (semver.valid(version)) {
              _this.installedAtomVersion = version;
            } else {
              _this.installedAtomVersion = '1.8.0';
              version = '1.8.0';
            }
            return callback();
          };
        })(this));
      } else {
        return this.loadInstalledAtomMetadata(callback);
      }
    };

) failed. So I am kind of stuck as to what to do.

Thanks for your time,
Brenton


#2

I found a solution, of sorts, I applied this patch:

--- a/lib/upgrade.js	2016-07-06 09:48:55.583624369 +1000
+++ b/lib/upgrade.js	2016-07-06 09:57:51.524481607 +1000
@@ -288,7 +285,8 @@
           if (_this.installedAtomVersion) {
             return _this.upgradePackages(options, callback);
           } else {
-            return callback('Could not determine current Atom version installed');
+            _this.installedAtomVersion = '1.8.0';
+            return _this.upgradePackages(options, callback);
           }
         };
       })(this));