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

FFI, WSL2, And Readmoo is blocked in China #8

Closed
HenryWu1031 opened this issue May 4, 2022 · 12 comments
Closed

FFI, WSL2, And Readmoo is blocked in China #8

HenryWu1031 opened this issue May 4, 2022 · 12 comments
Labels
documentation Improvements or additions to documentation

Comments

@HenryWu1031
Copy link

运行的时候一直报下图的错误,作者大大能否帮忙看下,感激不尽
issuepic

@NomadThanatos
Copy link
Owner

Based on your screenshot, I assume you are using WSL1/2.

For WSL1, you can install Chrome in your Windows, but I have not tested this since updating selenium for 4.

For WSL2, you have to install Chrome in your Linux environment as WSL2 is pretty like a independent virtual machine, and you can apply below fix to run it without GUI. But if requires reCAPTCHA it will fails. Since Windows 10 does not support WSLg, so I do not have any easy workaround until upgrade to Windows 11, I will add a workaround to bypass login via sending cookies to the program.

diff --git a/lib/readmoo_dl/API.rb b/lib/readmoo_dl/API.rb
index 05fe95d..d9db532 100644
--- a/lib/readmoo_dl/API.rb
+++ b/lib/readmoo_dl/API.rb
@@ -40,7 +40,12 @@ module ReadmooDL
     end

     def login
-      driver = Selenium::WebDriver.for :chrome
+      options = Selenium::WebDriver::Chrome::Options.new
+      options.add_argument('--headless')
+      options.add_argument('--no-sandbox')
+      options.add_argument('--disable-dev-shm-usage')
+
+      driver = Selenium::WebDriver.for :chrome, options: options
       driver.navigate.to(ReadmooDL::LOGIN_URL)

       driver = login_selenium(driver)

@HenryWu1031
Copy link
Author

首先非常感谢您的回复,我这边还是有几个问题
首先是我的ruby的版本是2.6.5,我在bundle install的时候会报这个错误
p1
然后我使用 sudo gem install llhttp-ffi这个命令是可以安装这个包的
p2
但是我使用命令去跑main.rb的时候又会报没有这两个包
image
然后我在命令上加sudo之后又可以跑起来了但是会报下面的错误
image
然后我用的是wsl,系统是win11。然后login方法已经修改成了您上述回复的内容
感谢您及时的回答 麻烦帮我看下这几个报错信息,不胜感激

@HenryWu1031
Copy link
Author

用的是wsl2 不好意思上面打错没加2

@NomadThanatos
Copy link
Owner

NomadThanatos commented May 4, 2022

For ffi you can install libffi-devel first, then gem install ffi --platform=ruby
And if ffi is installed, run sudo gem pristine --all to make it run with corresponding package.

I have not tested this under ruby2 anymore, if you have any issue with ruby2, please upgrade to ruby3.

@NomadThanatos
Copy link
Owner

And in the latest logs, I think the program runs well, the only issue is readmoo is blocked in China, so you have to bypass GFW.

@HenryWu1031
Copy link
Author

For ffi you can install libffi-devel first, then gem install ffi --platform=ruby And if ffi is installed, run sudo gem pristine --all to make it run with corresponding package.

I have not tested this under ruby2 anymore, if you have any issue with ruby2, please upgrade to ruby3.

我尝试了这种方法 并且把ruby的版本提升到了3.0.0 在wsl2中它依然会有上述的报错...

@HenryWu1031
Copy link
Author

然后我使用windows的话 运行program的报错会变成这样
image

@NomadThanatos
Copy link
Owner

It seems to be related to this issue,
docker/for-win#3171

@NomadThanatos
Copy link
Owner

NomadThanatos commented May 4, 2022

For ffi you can install libffi-devel first, then gem install ffi --platform=ruby And if ffi is installed, run sudo gem pristine --all to make it run with corresponding package.
I have not tested this under ruby2 anymore, if you have any issue with ruby2, please upgrade to ruby3.

我尝试了这种方法 并且把ruby的版本提升到了3.0.0 在wsl2中它依然会有上述的报错...

In the latest WSL2 logs, everything looks good to me except the website is blocked so you got a HTTP timeout.

@NomadThanatos NomadThanatos added the documentation Improvements or additions to documentation label May 4, 2022
@NomadThanatos NomadThanatos changed the title 运行报错 FFI, WSL2, And Readmoo is blocked in China May 4, 2022
@HenryWu1031
Copy link
Author

For ffi you can install libffi-devel first, then gem install ffi --platform=ruby And if ffi is installed, run sudo gem pristine --all to make it run with corresponding package.
I have not tested this under ruby2 anymore, if you have any issue with ruby2, please upgrade to ruby3.

我尝试了这种方法 并且把ruby的版本提升到了3.0.0 在wsl2中它依然会有上述的报错...

In the latest WSL2 logs, everything looks good to me except the website is blocked so you got a HTTP timeout.

https://stackoverflow.com/questions/69826792/ruby-bundle-install-fail
我发现这个提问的人跟我碰到的情况是一样的,不过他没有写他是怎么解决的

@NomadThanatos
Copy link
Owner

For ffi you can install libffi-devel first, then gem install ffi --platform=ruby And if ffi is installed, run sudo gem pristine --all to make it run with corresponding package.
I have not tested this under ruby2 anymore, if you have any issue with ruby2, please upgrade to ruby3.

我尝试了这种方法 并且把ruby的版本提升到了3.0.0 在wsl2中它依然会有上述的报错...

In the latest WSL2 logs, everything looks good to me except the website is blocked so you got a HTTP timeout.

https://stackoverflow.com/questions/69826792/ruby-bundle-install-fail 我发现这个提问的人跟我碰到的情况是一样的,不过他没有写他是怎么解决的

For ffi issue, you can check here: https://github.com/ffi/ffi/issues

@HenryWu1031
Copy link
Author

我最后解决了这个问题,最后的解决方法是换到linux系统就好了。我用的虚拟机的ubuntu版本是16.4,ruby版本是3.0.0,挂了梯子就可以运行这个项目。作者大大可以关闭这个issue了,非常感谢您的解答。thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants