bundle install returns "Could not locate Gemfile"

I'm new to Rails and am currently working through a guide. The guide states:

Use a text editor to update the Gemfile needed by Bundler with the contents of Listing 2.1.

source 'https://rubygems.org'


gem 'rails', '3.2.3'


group :development do
gem 'sqlite3', '1.3.5'
end




# Gems used only for assets and not required
# in production environments by default.


group :assets do
gem 'sass-rails',   '3.2.4'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end


gem 'jquery-rails', '2.0.0'


group :production do
gem 'pg', '0.12.2'
end

We then install and include the gems using the bundle install command:

    $ bundle install --without production

If Bundler complains about no such file to load -- readline (LoadError) try adding gem ’rb-readline’ to your Gemfile.)

I followed the steps even adding on gem 'rb-readline' to the Gemfile, but apparently the file can't be found and when I go to my text editor I do see the Gemfile itself. I noticed that they made me put gem 'rails', 3.2.3 and my version of Rails is 3.2.1 so I tried changing it to 3.2.1 but that didn't work either.

Any thoughts or advice would be much appreciated.

293402 次浏览

You just need to change directories to your app, THEN run bundle install :)

So I'd like to turn the question around. Why do you think Haskell does not need GC. How would you suggest memory allocation to be done?

Haskell is a non-strict programming language, but most implementations use call-by-need (laziness) to implement non-strictness. In call-by-need you only evaluate stuff when it is reached during runtime using the machinery of "thunks" (expressions that wait to be evaluated and then overwrite themselves, staying visible for their value to be reused when needed).

You must be in the same directory of Gemfile

Think more about what you are installing and navigate Gemfile folder, then try using sudo bundle install

Your intuition that this has something to do with purity has some truth to it.

ecause side effects of functions are accounted for in the type signature. So if a function has the side effect of printing something, there must be an IO somewhere in its return type.

But there is a function that is used implicitly everywhere in Haskell and whose type signature doesn't account for, what is in some sense, a side effect. Namely the function that copies some data and gives you two versions back. Under the hood this can work either literally, by duplicating the data in memory, or 'virtually' by increasing a debt that needs to be paid back later.

Haskell is considered pure partly because side effects of functions are accounted for in the type signature. So if a function has the side effect of printing something, there must be an IO somewhere in its return type.

It's possible to design languages with even more restrictive type systems (purely "linear" ones) that disallow the copy function. From the point of view of a programmer in such a language, Haskell looks a little impure.

But there is a function that is used implicitly everywhere in Haskell and whose type signature doesn't account for, what is in some sense, a side effect. Namely the function that copies some data and gives you two versions back. Under the hood this can work either literally, by duplicating the data in memory, or 'virtually' by increasing a debt that needs to be paid back later.

It's possible to design languages with even more restrictive type systems (purely "linear" ones) that disallow the copy function. From the point of view of a programmer in such a language, Haskell looks a little impure.

In fact, Clean, a relative of Haskell, has linear (more strictly: unique) types, and that can give some idea of what it would be like to disallow copying. But Clean still allows copying for "non-unique" types.

In fact, Clean, a relative of Haskell, has linear (more strictly: unique) types, and that can give some idea of what it would be like to disallow copying. But Clean still allows copying for "non-unique" types.

There is lots of research in this area and if you Google enough you'll find examples of pure linear code that requires no garbage collection. You'll find all kinds of type systems that can signal to the compiler what memory might be used allowing the compiler to eliminate some of the GC.

There is a sense in which quantum algorithms are also purely linear. Every operation is reversible and so no data can be created, copied, or destroyed. (They're also linear in the usual mathematical sense.)

There is lots of research in this area and if you Google enough you'll find examples of pure linear code that requires no garbage collection. You'll find all kinds of type systems that can signal to the compiler what memory might be used allowing the compiler to eliminate some of the GC.

It's also interesting to compare with Forth (or other stack based languages) which have explicit DUP operations that make clear when duplication is happening.

There is a sense in which quantum algorithms are also purely linear. Every operation is reversible and so no data can be created, copied, or destroyed. (They're also linear in the usual mathematical sense.)

Another (more abstract) way of thinking about this is to note that Haskell is built up from simply typed lambda calculus which is based on the theory of cartesian closed categories and that such categories come equipped with a diagonal function diag :: X -> (X, X). A language based on another class of category might have no such thing.

But in general, purely linear programming is too difficult to be useful, so we settle for GC.

It's also interesting to compare with Forth (or other stack based languages) which have explicit DUP operations that make clear when duplication is happening.

When I had similar problem gem update --system helped me. Run this before bundle install

Another (more abstract) way of thinking about this is to note that Haskell is built up from simply typed lambda calculus which is based on the theory of cartesian closed categories and that such categories come equipped with a diagonal function diag :: X -> (X, X). A language based on another class of category might have no such thing.

Search for the Gemfile file in your project, go to that directory and then run "bundle install". prior to running this command make sure you have installed the gem "sudo gem install bundler"

  • cd <foldername> OR cd !$ (that is magic ;)
  • bundle install
  • If you happen to be too lazy to click through to the strings package, here's example code:

    strings.ToLower("Hello, WoRLd") // => "hello, world"
    
  • bundle exec jekyll serve
  • Then in your browser just go to http://127.0.0.1:4000/ and it really should be running
  • All worked and goto your browser just go to http://127.0.0.1:4000/ and it really should be running

    ers are possible, then sometimes there is no other choice than string concatenation. Needing views on this issue.

    1. Make sure that the file name is Capitalized Gemfile instead of gemfile.
    2. Is there any advantage of using {} instead of string concatenation?

    3. Make sure you're in the same directory as the Gemfile.
    sudo gem install rails
    

    An example from slf4j

    logger.debug("Temperature set to {}. Old temperature was {}.", t, oldT);
    

    my problem solved, just this code.

    For those cases where you need more than 2 and you're stuck with pre-1.7 SLF4J, then just use either string concatenation or new Object[] { param1, param2, param3, ... }. There should be few enough of them that the performance is not as important.

    Short version: Yes it is faster, with less code!

    slf4j.org/apidocs/org/slf4j/Logger.html#debug%28java.lang.String,%20java.lang.Object%5B%5D%29" rel="noreferrer">http://slf4j.org/apidocs/org/slf4j/Logger.html#debug(java.lang.String, java.lang.Object[]).

    Regarding the speed: Ceki posted a benchmark a while back on one of the lists.