require

Ruby 2.0.0 cannot load such file even though gem is installed

懵懂的女人 提交于 2019-12-11 03:28:53
问题 I've tried all of the other solutions people have talked about on here, but none of them have helped / applied. I've written a Ruby script that requires the spreadsheet gem. The requiring works fine when I execute the script normally with ruby myscript.rb , but after running chmod +x myscript.rb , and then trying to run the program with ./myscript.rb I get the following error.... /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45

Load only what classes are being used in Ruby?

≡放荡痞女 提交于 2019-12-11 03:23:14
问题 If I load x.rb , then all the classes in that file are loaded. Is it possible to check and see what classes are being used and load those only? Assuming x.rb contains both Hello and Goodbye classes, and my program only uses the Hello Class, is it possible to load only the Hello Class? Happy with a script that checks the document, and outputs an .rb that has only the Hello Class and the code that uses it... Would be an interesting github project if doesn't exist, but I think it's out of my

ruby require problem (something to do with $LOAD_PATH)

元气小坏坏 提交于 2019-12-11 03:20:09
问题 I'm trying to use a gem i just installed (via sudo gem install excelsior ) like so require 'rubygems' require 'excelsior' ... This works fine in irb, but when I stick exactly the same code into an .rb file and try run it with ruby I get <internal:lib/rubygems/custom_require>:29:in require': no such file to load -- excelsior (LoadError) I guess it has something to do with the load paths apparently being completely different in irb from ruby (I'm on a mac and don't remember exactly how I

Uncaught ReferenceError: require is not defined

蹲街弑〆低调 提交于 2019-12-11 03:16:50
问题 I am trying to get the video uploader to work on my server i have node install on my server as root. i have installed the following in the folder where my node js file is cd /assets/js npm install socket.io npm install requirejs Then i run the node file with ]# node uploader.js info - socket.io started debug - served static content /socket.io.js and here is my uploader.js var app = require('http').createServer(handler) , io = require('socket.io').listen(app) , fs = require('fs') , exec =

How to include respond_to when you don't inherit from ApplicationController in Rails 4?

末鹿安然 提交于 2019-12-11 03:14:51
问题 I have an API controller in a Rails 4.1.2 app that does not inherit from Application controller. I'm trying to include the respond_to method and get a method undefined error....So then I required actionpack at the top like below: require 'action_pack' class Api::V1::UsersController < Api::ApiController version 1 doorkeeper_for :all respond_to :json def show respond_with current_user.as_json(except: :password_digest) end end and I still get ActionController::RoutingError (undefined method

Requiring a Ruby module in Rails console & controller

依然范特西╮ 提交于 2019-12-11 03:07:34
问题 I need the Ruby module FileUtils to handle some operations with files. I want to test that this require will work correctly in my controller. So I tried this in my console but got false as a result (this works fine when I'm not in a Rails console but just a plain Ruby console): Go to the root directory of my project $ rails c to open my console > require 'fileutils' returns false . What is the correct way to require a module via rails console? Why would this return false? I'm assuming in my

Why require.main.require.resolve is undefined?

こ雲淡風輕ζ 提交于 2019-12-11 02:59:06
问题 The question Whitin the scope of a node.js module there is a module object meant to be a reference to the current module , a require function meant to require modules and a require.resolve function meant to look up the location of a module but rather than load the module just return the resolved filename . If there is a module.require as there is a require , why there isn't a module.require.resolve as there is a require.resolve ? Or potentially the same thing: Why module.require !== require ?

PHP Require In different folders

廉价感情. 提交于 2019-12-11 02:57:02
问题 Okay so on my website I have a scripts folder which includes a php file which connects to mysql server so If I move a database then It will change it on all the files which are connect to the database. I also have another folder called templates. In that folder there is a top for the header and the footer. In the header template I wrote: require("../scripts/connect.php"); And I have another folder called, category. And that folder includes the header and the header includes connect. But then

How can I run my Perl script only if it wasn't loaded with require?

浪子不回头ぞ 提交于 2019-12-11 01:19:50
问题 I have a Perl script. If it was called direct from the command line, I want to run sub main . If it was called using require, I want to do nothing and wait for the caller script to call sub job at it's leisure. 回答1: There's a recommended Perl solution for code which needs to be runnable from a script as well as a perl module. It's usually called "modulino", which can be used as Google or SO search term to find how-tos. Here's one how-to with reference links: Perl script usable as a program

How to import ts file on js file firebase-functions

丶灬走出姿态 提交于 2019-12-10 22:21:18
问题 I am trying to import my ts file on some js file, when I am doing deploy I am getting error: Error: Error parsing triggers: Cannot find module 'EmailData' My code: the js file: var EmailDataClass = require("EmailData"); the ts file: class EmailData {} export EmailData; 回答1: good introduction: link node_modules folder. But only the index.js file is executed, you can reconfigure a main file through the main field of functions/package.json. You can see the source code from link 来源: https:/