binding.pry与命令bin/dev不起作用

发布于 2025-02-05 00:14:27 字数 163 浏览 4 评论 0原文

binding.pry不起作用(如果我使用bin/dev/dev命令启动服务器,则不可用)。它仅适用于bin/rails s命令。 我知道这与工头和copfile.dev有关,但我不知道如何。 这是一个错误还是应该像这样?

binding.pry not works(console input not available) if i start the server with bin/dev command. It only works with bin/rails s command.
I understand it has something to do with foreman and Procfile.dev, but I don't know how.
Is this a bug or is it supposed to be like this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

上课铃就是安魂曲 2025-02-12 00:14:28

使用bin/dev,procfile.dev文件与工头一起运行。撬问题是由CSS和JS观察者引起的:这些只是收听CSS和JS文件的更改。

您可以做的是删除Web:Unsot port&& bin/rails服务器 command conterfile,因此它只会具有CSS和JS观察者,并且看起来像这样:

js: yarn build --watch
css: yarn build:css --watch

现在您必须打开两个终端,一个带有bin/rails s以及另一个带有foreman start -f procfile.dev。这样,您的撬动是正常的,而观察者正常观看。

With bin/dev, the Procfile.dev file is run with foreman. The pry issue is caused by the CSS and JS watchers:these just listen to changes in your CSS and JS files.

What you can do is remove the web: unset PORT && bin/rails server command from your Procfile, so it will only have the CSS and JS watchers and look like this:

js: yarn build --watch
css: yarn build:css --watch

Now you'll have to open two terminals, one with bin/rails s and the other with foreman start -f Procfile.dev. This way your pry works in the server terminal as normal and the watchers are watching as normal.

音盲 2025-02-12 00:14:28

一种流行的方法是使用pry-remote,它在某些情况下没想到: https://github.com/mon-ouie/pry-remote

pry-remote打开一个远程终端,因此在删除调试器行(binding.remote_pry的情况下,在pry-remote)的情况下, 'll打开另一个终端,并通过在您的外壳中调用pry-remote来输入调试会话。

我得到的更为复杂,我已经习惯了,并且能够摆脱其他工艺所记录的噪音。

A popular approach is to use pry-remote which is useful in some ways I didn't expect: https://github.com/Mon-Ouie/pry-remote.

pry-remote opens a remote terminal, so where you drop your debugger line (binding.remote_pry in the case of pry-remote), you'll open another terminal and enter the debugging session by calling pry-remote in your shell.

I get this is a bit more complicated, I got used to it, and was able to get away from the noise logged by other process with Foreman.

半衬遮猫 2025-02-12 00:14:28

我使用rdbg + vscode远程调试,它可以正常工作。

像这样的更新procfile.dev使用Rails Server运行RDBG并设置插座文件

web: rdbg --command --nonstop --open=vscode --sock_path=tmp/sockets/rdbg.socket -- bundle exec bin/rails server

安装vscode ruby​​ rdbg调试器,配置启动。

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Attach to rdbg Process",
      "type": "rdbg",
      "request": "attach",
      "debugPort": "${workspaceRoot}/tmp/sockets/rdbg.socket",
    },
  ]
}

现在,json这样,VSCODE将在运行bin/dev时使用debugger启动启动,或者您可以在运行bin/dev时运行debugger in vscode by f5随时

I use rdbg + vscode remote debug and it works fine.

Update Procfile.dev like this to run rdbg with rails server and set a socket file

web: rdbg --command --nonstop --open=vscode --sock_path=tmp/sockets/rdbg.socket -- bundle exec bin/rails server

Install VSCode Ruby rdbg Debugger, configure launch.json like this

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Attach to rdbg Process",
      "type": "rdbg",
      "request": "attach",
      "debugPort": "${workspaceRoot}/tmp/sockets/rdbg.socket",
    },
  ]
}

Now, VSCode will launching with debugger enable while you run bin/dev, or you can run debugger in vscode by F5 anytime

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文