-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
react-native-git-upgrade changes nothing #12112
Comments
@joIivier how can I apply your patch locally? |
@ncuillery I have the same error from RN39 to RN41 |
@sibelius in cliEntry.js replace |
I think it should run |
This seems like a pretty basic thing for upgrading react native and I don't understand why more people aren't complaining about it. I've been unable to use this tool successfully and have reinstalled multiple times. Any updates here? |
@joIivier where in /**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
*/
'use strict';
const Config = require('./util/Config');
const assertRequiredOptions = require('./util/assertRequiredOptions');
const chalk = require('chalk');
const childProcess = require('child_process');
const commander = require('commander');
const commands = require('./commands');
const defaultConfig = require('./default.config');
const init = require('./init/init');
const minimist = require('minimist');
const path = require('path');
const pkg = require('../package.json');
import type {Command} from './commands';
import type {ConfigT} from './util/Config';
commander.version(pkg.version);
const defaultOptParser = (val) => val;
const handleError = (err) => {
console.error();
console.error(err.message || err);
console.error();
process.exit(1);
};
// Custom printHelpInformation command inspired by internal Commander.js
// one modified to suit our needs
function printHelpInformation() {
let cmdName = this._name;
if (this._alias) {
cmdName = cmdName + '|' + this._alias;
}
const sourceInformation = this.pkg
? [
` ${chalk.bold('Source:')} ${this.pkg.name}@${this.pkg.version}`,
'',
]
: [];
let output = [
'',
chalk.bold(chalk.cyan((` react-native ${cmdName} ${this.usage()}`))),
` ${this._description}`,
'',
...sourceInformation,
` ${chalk.bold('Options:')}`,
'',
this.optionHelp().replace(/^/gm, ' '),
'',
];
if (this.examples && this.examples.length > 0) {
const formattedUsage = this.examples.map(
example => ` ${example.desc}: \n ${chalk.cyan(example.cmd)}`,
).join('\n\n');
output = output.concat([
chalk.bold(' Example usage:'),
'',
formattedUsage,
]);
}
return output.concat([
'',
'',
]).join('\n');
}
function printUnknownCommand(cmdName) {
console.log([
'',
cmdName
? chalk.red(` Unrecognized command '${cmdName}'`)
: chalk.red(' You didn\'t pass any command'),
` Run ${chalk.cyan('react-native --help')} to see list of all available commands`,
'',
].join('\n'));
}
const addCommand = (command: Command, config: ConfigT) => {
const options = command.options || [];
const cmd = commander
.command(command.name, undefined, {
noHelp: !command.description,
})
.description(command.description)
.action(function runAction() {
const passedOptions = this.opts();
const argv: Array<string> = Array.from(arguments).slice(0, -1);
Promise.resolve()
.then(() => {
assertRequiredOptions(options, passedOptions);
return command.func(argv, config, passedOptions);
})
.catch(handleError);
});
cmd.helpInformation = printHelpInformation.bind(cmd);
cmd.examples = command.examples;
cmd.pkg = command.pkg;
options
.forEach(opt => cmd.option(
opt.command,
opt.description,
opt.parse || defaultOptParser,
typeof opt.default === 'function' ? opt.default(config) : opt.default,
));
// Placeholder option for --config, which is parsed before any other option,
// but needs to be here to avoid "unknown option" errors when specified
cmd.option('--config [string]', 'Path to the CLI configuration file');
};
function getCliConfig() {
// Use a lightweight option parser to look up the CLI configuration file,
// which we need to set up the parser for the other args and options
const cliArgs = minimist(process.argv.slice(2));
let cwd;
let configPath;
if (cliArgs.config != null) {
cwd = process.cwd();
configPath = cliArgs.config;
} else {
cwd = __dirname;
configPath = Config.findConfigPath(cwd);
}
return Config.get(cwd, defaultConfig, configPath);
}
function run() {
const setupEnvScript = /^win/.test(process.platform)
? 'setup_env.bat'
: 'setup_env.sh';
childProcess.execFileSync(path.join(__dirname, setupEnvScript));
const config = getCliConfig();
commands.forEach(cmd => addCommand(cmd, config));
commander.parse(process.argv);
const isValidCommand = commands.find(cmd => cmd.name.split(' ')[0] === process.argv[2]);
if (!isValidCommand) {
printUnknownCommand(process.argv[2]);
return;
}
if (!commander.args.length) {
commander.help();
}
}
module.exports = {
run: run,
init: init,
}; |
@joIivier @ncuillery Made a video showing my struggles lol. Any suggestions here would be greatly appreciated as our current method of upgrading, completely manual, is a total PITA. |
Just tried on a coworkers computer who is in the same repo as us and got the exact same results. |
Why my cliEntry.js doesn't the same to you i can't find the line @sibelius |
I discovered that a I took a look at this file, and sure enough, there's all my diffs. So then I use Working reproducible steps
|
Having this issue going from .40 to .42.3. On first try, merge conflicts registered in the proper files. But subsequent tries yielded no such luck and required the reject flag for any discernible conflict. |
What seems to cause thisThis issue is reproducible when the diff between the React Native project template files have changed (between your current RN version and the newest RN version) in one of the following ways:
The core issueAs others have identified, the upgrade process creates a patch file, then tries to apply the patch. When it tries to apply a If you change the git strategy for applying the patch from @sibelius and @whk1459086640, you should be looking for |
Upgrading shouldn't require finding a hidden temp file or editing a library file. The simplest workaround would probably be adding a cli argument to |
It seems like the patch should be agnostic as to the state of the thing needing to be upgraded, e.g. it should look to patch a version without caring about what the version number ought to have been previously. This is especially the case because both Android Studio and Xcode will upgrade native config stuff as needed, not to mention the need to manually upgrade specific lines as certain libraries might demand. |
Running into this same problem on mac upgrading from react-native 0.43.3 to v0.44.3
When running a git status only the gradle windows file is changed:
Edit: Following the steps of #12112 (comment) worked for me However i needed to apply some extra args to git apply --reject --whitespace=fix $TMPDIR/react-native-git-upgrade/upgrade_0.43.3_0.44.3.patch |
Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally! If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:
If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution. |
This issue still persists |
FIX facebook#12112 Per facebook#12112 (comment) : "As others have identified, the upgrade process creates a patch file, then tries to apply the patch. When it tries to apply a --3way patch, it will fail if it encounters any errors such as those above ☝️. Unfortunately, it reverses the whole patch when a 3-way patch fails to apply. If you change the git strategy for applying the patch from --3way to --reject, it will allow your changes to go through, then you just have to resolve and remove the .rej files where it had errored out. You can either do this after it fails using the patch file @ajwhite found, or change the cliEntry.js directly as described in the PR description."
PR #17266 |
Summary: The upgrade script uses `git apply --3way`: https://github.com/facebook/react-native/blob/4906f8d28cdbaf1b432494b473a4c61c1e193881/react-native-git-upgrade/cliEntry.js#L368-L369 If you've already upgraded something that React Native upgraded, this will silently fail. For example if you have already upgraded Gradle to the version available in the new version of React Native, the 3-way patch will fail. In this case, the upgraded version is installed into `node_modules` but `package.json` is not updated. More context, discussion, and information is in #12112 (comment). Until a more robust solution is implemented, this PR proposes to mitigate the effects of the problem by informing the user of the possible issue and instructing them of a workaround. In an affected project, I ran `react-native-git-upgrade` after applying my patch. As expected, I now receive the following output: ![image](https://user-images.githubusercontent.com/789577/38165770-6209ac68-34de-11e8-9d96-7c782e9ef7ce.png) After running the suggested command, `git status` now shows me the two rejections: ![image](https://user-images.githubusercontent.com/789577/38165796-d10ca7c8-34de-11e8-9037-8427513e3a84.png) And I can now [manually apply](https://stackoverflow.com/a/28569128/1445366) these changes. [CLI] [ENHANCEMENT] [react-native-git-upgrade/cliEntry.js] - Provide instructions for upgrading React Native when 3-way merges don't apply Closes #18636 Differential Revision: D7603073 Pulled By: hramos fbshipit-source-id: 32d387e1ee67d8b182d248c585cd33ba94808357
Looks like this issue will be fixed (via more helpful error message) when 4fbd244 is released |
Summary: The upgrade script uses `git apply --3way`: https://github.com/facebook/react-native/blob/4906f8d28cdbaf1b432494b473a4c61c1e193881/react-native-git-upgrade/cliEntry.js#L368-L369 If you've already upgraded something that React Native upgraded, this will silently fail. For example if you have already upgraded Gradle to the version available in the new version of React Native, the 3-way patch will fail. In this case, the upgraded version is installed into `node_modules` but `package.json` is not updated. More context, discussion, and information is in facebook#12112 (comment). Until a more robust solution is implemented, this PR proposes to mitigate the effects of the problem by informing the user of the possible issue and instructing them of a workaround. In an affected project, I ran `react-native-git-upgrade` after applying my patch. As expected, I now receive the following output: ![image](https://user-images.githubusercontent.com/789577/38165770-6209ac68-34de-11e8-9d96-7c782e9ef7ce.png) After running the suggested command, `git status` now shows me the two rejections: ![image](https://user-images.githubusercontent.com/789577/38165796-d10ca7c8-34de-11e8-9037-8427513e3a84.png) And I can now [manually apply](https://stackoverflow.com/a/28569128/1445366) these changes. [CLI] [ENHANCEMENT] [react-native-git-upgrade/cliEntry.js] - Provide instructions for upgrading React Native when 3-way merges don't apply Closes facebook#18636 Differential Revision: D7603073 Pulled By: hramos fbshipit-source-id: 32d387e1ee67d8b182d248c585cd33ba94808357
still happening |
This is fixed in 4fbd244 |
Description
I am trying to upgrade from react native 35 to 40. Running 'react-native-git-upgrade' in my project tells me the upgrade has been done but nothing has changed in my repository.
Output:
Then I look in my status
Nothing. No conflict.
This is the ouptut after I ignored *.png in my global gitignore file (as per issue #11402). I had previously also warning related to the png files (although I never changed this part of the project since I'm only doing iOs for now).
After this script is run I get react native 40 in my node modules, but I couldn't build the project on Xcode which was complaining about the React native libraries of my project.
Solution
I guess the critical lines in the logs are the "without full index line" errors for the binaries I don't have (maybe because I never ran the android project) and the "does not exist in index" that is thrown for AppDelegate.m (I use swift instead).
I managed to get it to work by changing in cliEntry.js
git apply --3way ${patchPath}
bygit apply --reject ${patchPath}
which worked (I could start correctly my application afterwards) but I will have to merge manually the conflicts now.I guess you should at least test the output code of git apply to detect a failure and print a valid error message, and maybe suggest to retry with --reset instead of --3way if the --3way failed.
Additional Information
The text was updated successfully, but these errors were encountered: