Skip to content
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

Cocoapods: Fix deprecated/removed File.exists method #3919

Merged
merged 1 commit into from
Jan 9, 2023
Merged

Cocoapods: Fix deprecated/removed File.exists method #3919

merged 1 commit into from
Jan 9, 2023

Conversation

iBotPeaches
Copy link
Contributor

Noticed on accident when I upgraded Ruby on accident to 3 - that my pod install failed with:

[!] Invalid `Podfile` file: 
[!] Invalid `RNReanimated.podspec` file: undefined method `exists?' for File:Class.

 #  from /Users/xx/iOSProjects/xx-app/node_modules/react-native-reanimated/RNReanimated.podspec:5
 #  -------------------------------------------
 #  reanimated_package_json = JSON.parse(File.read(File.join(__dir__, "package.json")))
 >  config = find_config()

Theres a good deal of other errors after I fixed this one on other projects, but this looks like a safe change to get ahead of the future Ruby upgrade. Yeah I did downgrade back to 2.7.5.

Summary

Resolves the removed method of File.exists in Ruby3. The alternative method of File.exist is recommended and already exists on 2.5 for no breaking changes.

https://rubyapi.org/2.5/o/file#method-c-exist-3F

Test plan

A local working pod install

Copy link
Member

@piaskowyk piaskowyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR! 🚀

@iBotPeaches
Copy link
Contributor Author

I'm getting this error too. But I don't understand how I can fix it with this, can you explain?

I thought my explanation was pretty detailed - what part are you lost on?

piaskowyk pushed a commit that referenced this pull request Jan 10, 2023
Noticed on accident when I upgraded Ruby on accident to 3 - that my `pod install` failed with:

```
[!] Invalid `Podfile` file: 
[!] Invalid `RNReanimated.podspec` file: undefined method `exists?' for File:Class.

 #  from /Users/xx/iOSProjects/xx-app/node_modules/react-native-reanimated/RNReanimated.podspec:5
 #  -------------------------------------------
 #  reanimated_package_json = JSON.parse(File.read(File.join(__dir__, "package.json")))
 >  config = find_config()
```

Theres a good deal of other errors after I fixed this one on other projects, but this looks like a safe change to get ahead of the future Ruby upgrade. Yeah I did downgrade back to 2.7.5.

## Summary

Resolves the removed method of `File.exists` in Ruby3. The alternative method of `File.exist` is recommended and already exists on 2.5 for no breaking changes.

https://rubyapi.org/2.5/o/file#method-c-exist-3F

## Test plan

A local working `pod install`
@raulglezrdguez
Copy link

go to:
Project/node_modules/react-native-reanimated/scripts/reanimated_utils.rb
and change File.exists for File.exist

j-piasecki pushed a commit to software-mansion/react-native-gesture-handler that referenced this pull request Jan 12, 2023
@billnbell
Copy link

Is this being released?

@LukasMod
Copy link

If you use patch package here is a file working with 2.12:

react-native-reanimated+2.12.0.patch

diff --git a/node_modules/react-native-reanimated/scripts/reanimated_utils.rb b/node_modules/react-native-reanimated/scripts/reanimated_utils.rb
index 481cb3a..b613361 100644
--- a/node_modules/react-native-reanimated/scripts/reanimated_utils.rb
+++ b/node_modules/react-native-reanimated/scripts/reanimated_utils.rb
@@ -1,6 +1,6 @@
 def try_to_parse_react_native_package_json(node_modules_dir)
   react_native_package_json_path = File.join(node_modules_dir, 'react-native/package.json')
-  if !File.exists?(react_native_package_json_path)
+  if !File.exist?(react_native_package_json_path)
     return nil
   end
   return JSON.parse(File.read(react_native_package_json_path))

facebook-github-bot pushed a commit to facebook/react-native that referenced this pull request Jan 17, 2023
…35853)

Summary:
Remove deprecated `File.exists` method which was removed in later Ruby versions. Spotted during a brew upgrade [here](software-mansion/react-native-reanimated#3919).

https://rubyapi.org/2.5/o/file#method-c-exist-3F

```
Fetching podspec for `hermes-engine` from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`
[!] Failed to load 'hermes-engine' podspec:
[!] Invalid `hermes-engine.podspec` file: undefined method `exists?' for File:Class.
 #  from [..]/node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec:46
 ```

## Changelog

[IOS] [FIXED] - Migrated `File.exists` from Hermes podspec for non-deprecated `File.exist`.

Pull Request resolved: #35853

Test Plan: Valid CI via CircleCI.

Reviewed By: dmytrorykun

Differential Revision: D42543148

Pulled By: cipolleschi

fbshipit-source-id: 5ed30d8cc3e4c91a6e86d51f7d44a125bf85f7e8
OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this pull request May 22, 2023
…acebook#35853)

Summary:
Remove deprecated `File.exists` method which was removed in later Ruby versions. Spotted during a brew upgrade [here](software-mansion/react-native-reanimated#3919).

https://rubyapi.org/2.5/o/file#method-c-exist-3F

```
Fetching podspec for `hermes-engine` from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`
[!] Failed to load 'hermes-engine' podspec:
[!] Invalid `hermes-engine.podspec` file: undefined method `exists?' for File:Class.
 #  from [..]/node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec:46
 ```

## Changelog

[IOS] [FIXED] - Migrated `File.exists` from Hermes podspec for non-deprecated `File.exist`.

Pull Request resolved: facebook#35853

Test Plan: Valid CI via CircleCI.

Reviewed By: dmytrorykun

Differential Revision: D42543148

Pulled By: cipolleschi

fbshipit-source-id: 5ed30d8cc3e4c91a6e86d51f7d44a125bf85f7e8
fluiddot pushed a commit to wordpress-mobile/react-native-reanimated that referenced this pull request Jun 5, 2023
…n#3919)

Noticed on accident when I upgraded Ruby on accident to 3 - that my `pod install` failed with:

```
[!] Invalid `Podfile` file: 
[!] Invalid `RNReanimated.podspec` file: undefined method `exists?' for File:Class.

 #  from /Users/xx/iOSProjects/xx-app/node_modules/react-native-reanimated/RNReanimated.podspec:5
 #  -------------------------------------------
 #  reanimated_package_json = JSON.parse(File.read(File.join(__dir__, "package.json")))
 >  config = find_config()
```

Theres a good deal of other errors after I fixed this one on other projects, but this looks like a safe change to get ahead of the future Ruby upgrade. Yeah I did downgrade back to 2.7.5.

## Summary

Resolves the removed method of `File.exists` in Ruby3. The alternative method of `File.exist` is recommended and already exists on 2.5 for no breaking changes.

https://rubyapi.org/2.5/o/file#method-c-exist-3F

## Test plan

A local working `pod install`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants