'require 'rmagick' 和 'require RMagick' 之间的区别(Mac vs Debian) [英] Difference between 'require 'rmagick' and 'require RMagick' (Mac vs Debian)

查看:18
本文介绍了'require 'rmagick' 和 'require RMagick' 之间的区别(Mac vs Debian)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Mac pro Lion 进行 ImageMagick Q16、RVM 和 ruby​​ 1.8.7 的开发

I'm using a Mac pro Lion for development with ImageMagick Q16, RVM and ruby 1.8.7

我可以在 IRB 中使用以下内容:

I can use the following in IRB:

require 'rubygems'
=> true 
require 'rmagick'
=> true 
require 'RMagick'
LoadError: no such file to load -- RMmagick

在我的 Debian Squeeze 6.0 生产服务器上使用 ImageMagick Q16、RVM 和 ruby​​ 1.8.7

On my Debian Squeeze 6.0 production server with ImageMagick Q16, RVM and ruby 1.8.7

我可以在 IRB 中使用以下内容:

I can use the following in IRB:

require 'rubygems'
=> true 
require 'rmagick'
LoadError: no such file to load -- rmagick 
require 'RMagick'
=> true

'gem list' 在两个操作系统上都以小写形式显示.

'gem list' shows on both OS's in lowercase.

rmagick (2.13.1)

我想知道这个问题的根源?

I would like to know the root of this problem?

gem 的大小写(如 gem 列表中所示)是否应该与 require 'some_gem'

Should the capitalisation of the gems (as shown in the gem list) not be the same as in the require 'some_gem'

推荐答案

造成这种情况的根本原因是 Mac OS X 上的文件系统默认不区分大小写.如果需要,可以在命令行上进行快速测试以确认这一点.

The root cause of this it that the filesystem on Mac OS X is case insensitive by default. You can do a quick test to confirm this if you want on the command line.

touch testcase
touch Testcase
ls

如果您只看到一个测试用例文件,那么您可能在不区分大小写的 fs 上.或者,您可以执行以下操作:

If you only see only one testcase file then your probably on a case insensitive fs. Alternatively you can do something like:

diskutil info /

如果你看到了结果中

File System Personality: Journaled HFS+ 

而不是

File System Personality: Case-sensitive Journaled HFS+.

那么你的大小写不敏感.如果您不敏感,那么这就是您可以摆脱要求RMagick"或rmagick"或任何其他大写模式的原因.作为Cameron 指出您包含的大写的 lib 文件,请参见:https://github.com/rmagick/rmagick/blob/master/lib/RMagick.rb 这意味着当您使用区分大小写的 fs 时,您将不得不

then your case insensitive. If your insensitive then that is what allows you to get away with requiring 'RMagick' or 'rmagick' or any other capitalization pattern. As Cameron points out the lib file that your including is capitalized see: https://github.com/rmagick/rmagick/blob/master/lib/RMagick.rb This means that when you are on a case sensitive fs you will have to

require 'RMagick'

作为

require 'rmagick'

查找不存在的文件.

我已经看到了很多这样的问题,特别是如果你的 git repo 在同一个文件夹中有两个具有相同名称和不同大小写的文件(对我来说,这导致 git 总是报告未提交的更改).对于它的价值,我使用磁盘实用程序来创建我安装并用于开发的区分大小写的磁盘映像.这样我就可以保留默认的不区分大小写的 fs 并避免此类烦人的问题.

I have seen a lot of issues with this especially if your git repo has two files with the same name and different cases in the same folder (for me this results in git always reporting uncommitted changes). For what its worth I used disk utility to create case sensitive disk image that I mount and use for development. That way I can leave the default case insensitive fs in place and avoid annoying issues like this.

这篇关于'require 'rmagick' 和 'require RMagick' 之间的区别(Mac vs Debian)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆