It turned out to be a permissions issue. I issued the db2set command locally, as the instance owner (db2inst1 in this case), but the instance owner did not have permissions to write to the default.env file because they were not in the 'root' group. (default.env is created by root, I'm guessing, as part of installation). So either giving default.env world write permissions or adding db2inst1 to the root group works.